Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

How to make a Java Main Menu Loop after using a case

    //set choiceentry to -1, this will make it to enter while loop
     int choiceentry = -1

    while(choiceentry < 1 || choiceentry > 3){

            System.out.println("Enter "1", "2", "3" or "4"");
            if(scanchoice.hasNextInt())
            choiceentry = scanchoice.nextInt();

    }

     switch(choiceentry){
        case 1:
           //do logic
           break;
        case 2:
           //do logic
           break;
        case 3:
           //do logic
           break;
   }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #How #Java #Main #Menu #Loop #case
ADD COMMENT
Topic
Name
6+9 =