Method menu


Im really new to java and i need to make methods for this menu.

But before i start i want to get the “menu” to come up when i click run in netbeans.

Ive added a main class, and it says its built successfully but it doesnt prompt any output

can anyone help me with this? I am totally confused?:confused:

Ive attached the code below:confused:

[COLOR=“Navy”]package students;

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 out = System.out;
private ReadKb reader = new ReadKb();
/** Creates a new instance of Main */
public Main() {

private void run(){
    int ret = mainMenu.display();
            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){
            case 1: addStudent();break;
            case 2: listStudents(); break;
            case 3: findStudent(); break;
        ret = studentMenu.display();
private void lecturers(){

Lecturers not yet implemented");
private void admin(){
Admin not yet implemented");
//Student methods
private void addStudent(){
\ Add New Student");
//prompt for details
//add student to the datastore
//ask if they want to enter another student -
// if so call addStudent again
//otherwise the method completes and the studentMenu will display again

private void listStudents(){

\ Student Listing");
//list all students from the datastore
private void findStudent(){
\ Find Student");
out.print("Enter Search String: ");
//reasd search text
//use datastore method to get list of students that contain the search string
//display matching students

// end Student methods
private void exit() {;  //call the datastore method that will save to file

Goodbye :)");

Welcome to the wonderful world of Java.

Let me start with this: programming is like math, doing advanced things requires the programmer to understand how to do basic things.

You say the code compiles, that’s great, but it doesn’t mean the code works. It only means that the code is free of syntax errors, obvious logic errors, cast conflicts and many, many other things that the compiler looks for.

When you ask Java to execute a class, it looks for, and executes, the main method.

Your main method is, and must be, static. When we give a method or variable the static modifier, that item is said to exist without an Instance of the class being created.

That said, when Java ‘executes’ your class, it does not create an Instance of your class, it simply looks for a main method which, being static, it can execute. It will complain if it doesn’t find one.

Your main method does nothing, therefore, your class does nothing.

Create an Instance of Main within your main method and it’ll go.

Thank you soooo much rushiku,

Its working now AND i have a clearer understanding of why and how!!:smiley: