Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

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

int choiceentry;

do {
    System.out.println("Enter "1", "2" or "3"");
    choiceentry = scanchoice.nextInt();

    switch (choiceentry)
    {
        case 1:
            // do something
            break;
        case 2: 
            // ..something else
            break;
        case 3: 
            // .. exit program
            break;
        default:
            System.out.println("Choice must be a value between 1 and 3.");
    }   
} while (choiceentry != 3);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #How #Java #Main #Menu #Loop #case
ADD COMMENT
Topic
Name
4+6 =