📜  使用案例后如何制作java主菜单循环 - Java代码示例

📅  最后修改于: 2022-03-11 14:52:29.008000             🧑  作者: Mango

代码示例4
//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;
   }