关于Java分行输入int值和String值

`Scanner in=new Scanner(System.in);
Integer fistNum=in.nextInt();
String fuhao=in.nextLine();
Integer secondNum=in.nextInt();`

这里的输出会报错
选区_008.png

解决方案:
可以创建两个输入对象
`Scanner in1=new Scanner(System.in);
Scanner in2=new Scanner(System.in);
Integer fistNum=in1.nextInt();
String fuhao=in2.nextLine();
Integer secondNum=in1.nextInt();`

评论

暂无评论