Hi,
Im using netbeans and i keep getting a illegal start of exspression error alert ive made the line red:confused:
heres surrounding code;
[COLOR=“Blue”]public class Main {
public static void main(String[] args) {
private final static String[] mainMenuOpts = {“Students”,“Lecturers”,“Admin”,“Exit”};
private final static String studentMenuOpts = {“Add Student”,“List all Students”,“Find a Student”,“Return to Main Menu”};
private Menu mainMenu = new Menu(“MAIN MENU”,mainMenuOpts);
private Menu studentMenu = new Menu(“STUDENT MENU”,studentMenuOpts);
private DataStore data = new DataStore();
private java.io.PrintStream out = System.out;
private ReadKb reader = new ReadKb();
/** Creates a new instance of Main */
public Main() {
run();
}[/COLOR]
public method cannot have private variables.
Remove “private” as modifier.
Also is this the Full code? because i see more Syntactical errors like defining constructor in main method “public Main()”
More correctly: a method variable may have no modifier other than final.
Your class should look like more the following to be valid Java code:
public class Main {
private final static String[] mainMenuOpts = {"Students","Lecturers","Admin","Exit"};
private final static String[] studentMenuOpts = {"Add Student","List all Students","Find a Student","Return to Main Menu"};
private Menu mainMenu = new Menu("MAIN MENU",mainMenuOpts);
private Menu studentMenu = new Menu("STUDENT MENU",studentMenuOpts);
private DataStore data = new DataStore();
private java.io.PrintStream out = System.out;
private ReadKb reader = new ReadKb();
public Main() {
run();
}
public void run(){
//do something in here when object is created
}
/** Creates a new instance of Main */
public static void main(String[] args) {
Main myMain = new Main();
}
}