的输入。在下面的代码:扫描器不是问串
secondI = scan.nextInt();
System.out.println("double");
secondD = scan.nextDouble();
System.out.println("string");
secondS = scan.nextLine();
进入双值后,将其跳过字符串项部分。我怎样才能解决这个问题?
的输入。在下面的代码:扫描器不是问串
secondI = scan.nextInt();
System.out.println("double");
secondD = scan.nextDouble();
System.out.println("string");
secondS = scan.nextLine();
进入双值后,将其跳过字符串项部分。我怎样才能解决这个问题?
secondI = scan.nextInt();
System.out.println("double");
secondD = scan.nextDouble();
scan.nextLine();
System.out.println("string");
secondS = scan.nextLine();
你需要有这个额外nextline声明消耗你的双重价值进入该行的其余部分。的
secondS = scan.nextLine();
使用
secondS = scan.next();
,而不是请参阅documentation for Scanner.nextLine()
。
将此扫描仪推进到当前行并返回跳过的输入。使用
Scanner
类的其他方法