Home > Back-end >  The switch choose how to call the corresponding method to realize in the structure function menu?
The switch choose how to call the corresponding method to realize in the structure function menu?

Time:09-26

Requirements in the work method cycle structure shown in the menu, and then the receive user input into the menu, and enter a student number, call the corresponding method to realize the menu function, until the user input 0, then exit the loop
The main method in the same package ready in the class is the choice of the method of the work here not fix the

CodePudding user response:

This is very simple, you can't directly use the input. The nextInt (), to create a Scanner object, Scanner input=new Scanner (System. In);
Int s=input again. NextInt (); Student number, after you enter the switch input. Can directly use the input nextInt, Scanner object has been created,

CodePudding user response:

reference 1st floor dhacker1 response:
this is very simple, you can't directly use the input. NextInt (), to create a Scanner object, Scanner input=new Scanner (System. In);
Int s=input again. NextInt (); Student number, after you enter the switch input. Can directly use the input nextInt, Scanner object has been created,
do not understand,,
  • Related