ok changed the program around using methods like you suggested but for some reason it wont loop back round to main menu can anyone see why all it keeps doing is running the sub menu and if i place loop further up it just runs but no window opens
//This program will provide a menu system for inputting //data regards 3 taxi's import java.util.Scanner;//importing the scanner utility class c22taxis { public static void menu() //This method will be called by the main method later { //printing of the system menu on screen to user System.out.println("Welcome to C22 Taxis automated System"); System.out.println("");// blank line System.out.println("Please select from a option below to continue."); System.out.println("");// blank line System.out.println(" 1. Enter/Change Driver Name."); System.out.println("");// blank line System.out.println(" 2. Enter/Change veichle booking status."); System.out.println("");// blank line System.out.println(" 3. Enter/Change veichle service status."); System.out.println("");// blank line System.out.println(" 4. List all veichle status"); System.out.println("");// blank line System.out.println(" 5. Exit");//exit command for program System.out.println(""); System.out.print("Please select a option: "); } public static void main (String[]args) { //initialising the scanner Scanner input = new Scanner(System.in); //creating/initialising the variables String taxi1, taxi2,taxi3; String [] name = new String[3];//name array useable upto as many names as required String [] dest = new String [3];//array for destination again as many taxis as required int choice = 0, preference; int tNo = 0; menu();//calling the method /main menu preference = input.nextInt(); while (preference !=5) { if (preference == 1)// path of input from user { System.out.println('\f'); // sub menu for driver change details System.out.println(" Driver name sub Menu"); System.out.println(""); System.out.println(""); System.out.print("Please enter taxi number: "); tNo = input.nextInt();//instruction for user to input number //if/else relating to choice made in sub menu will then prompt user for tsxi no. and then name //name then goes in relevant array position. switch (tNo) { case 1: System.out.print("Please enter drivers name: "); name[0] = input.next(); break; case 2: System.out.print("Please enter drivers name: "); name[1] = input.next(); break; case 3: System.out.print("Please enter drivers name: "); name[2] = input.next(); break; //the default default: System.out.print("invalid entry return to menu."); menu(); break; } }