Syntax error on token ";", { expected after this token.
I got this error on the 11th line and 19th line. Is there anyone can tell me what’s the problem with it?
import java.util.*;
class veding_machine{
State st;
veding_machine vm;
private int price;
private int k;
private int k1;
private int t;
private int s;
State Ls[]=new State[7]; // 11th line
Ls[0]=idle;
Ls[1]=coins_inserted;
Ls[2]=sugar;
LS[3]=nsc;
Ls[4]=nlc;
Ls[5]=et;
Ls[6]=st; // 19th line
public veding_machine(){ k=0; k1=0; t=0; price=0;
}
public void setK(int k){
this.k=k;
}
The initialization of Ls should be inside the vending_machine constructor and should be creating instances of the classes “idle” and “coins_inserted”, etc…
and these classes need to extend the State class
They don’t need a state instance inside them.