I am learning Java for my course and I hit a brick wall. I was tasked with developing a simple command line program. To simplify the task, I was provided with the following sample code to modify, so I would not have to start from scratch.
package assignment; 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(); } private void run(){ int ret = mainMenu.display(); while(true){ switch(ret){ case 1: students();break; case 2: lecturers(); break; case 3: admin(); break; case 4: exit(); break; } ret = mainMenu.display(); } } private void students(){ int ret = studentMenu.display(); while(ret != 4){ switch(ret){ case 1: addStudent();break; case 2: listStudents(); break; case 3: findStudent(); break; } ret = studentMenu.display(); } } private void lecturers(){ out.println("\nLecturers not yet implemented"); } private void admin(){ out.println("\nAdmin not yet implemented"); }
I am using NetBeans, and when I try to start a project, I get this error:
Error: Main method not found in class assignment.Main, please define the main method as: public static void main(String[] args)
I just want to run the program to better understand the code. I understand the error, but I have no idea where to implement the main method in this text wall. I experimented for hours, but obviously, as a beginner, I am completely useless. Any help would be greatly appreciated.
source share