StringuserIptNum,userIptPsw;Scannerkeyboard=newScanner(System.in);while(true){menu();if(keyboard.hasNextInt()){intoption=keyboard.nextInt();switch(option){case1:System.ou...
String userIptNum, userIptPsw;
Scanner keyboard = new Scanner(System.in);
while (true)
{
menu();
if (keyboard.hasNextInt())
{
int option = keyboard.nextInt();
switch (option)
{
case 1:
System.out.println("Please input your student Number: ");
userIptNum = keyboard.nextLine();
System.out.println("Please input your student Password: ");
userIptPsw = keyboard.nextLine();
case 2:
System.out.println("*** THE END ***");
return ;
default:
System.out.println("Unrecognized option!");
continue;
}
}
else
{
keyboard.next();
//continue;
}
}
问题在于执行的时候,电脑不会停下来等用户输入学号,然后再提示输入密码,而是把两行全部显示在屏幕上之后再提示你输入!!!
怎么搞的? 能人解释下。
展开