我现在很难解决这个问题。 所以,我有这个代码片断,询问用户的3个输入。扫描仪输入跳过下一个输入
case 0:
String accnum,pin,name;
System.out.print("Enter account name: ");
name = input.nextLine();
System.out.print("Enter account number: ");
accnum = input.next();
System.out.print("Enter account PIN: ");
pin = input.next();
atm.set_accinfos(name,accnum,pin);
//System.out.print(atm.return_acc() + "\t" + atm.return_pin() + "\n");
break;
但每次我运行它,它总是跳过输入字符串“名字”,我尝试使用input.next();就可以了,但它现在会跳过字符串“accnum”的输入。
编辑:它也恰好发生如果从“名称”的输入上有一个空间,例如:约翰·多伊。
我在这里错过了什么吗?
你是否在这段代码之前使用同一个扫描器? – 2014-10-16 14:08:03
@LukeWillis - 其实这是一个很好的观点。 – TheLostMind 2014-10-16 14:09:58