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

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

这里的输入会报错

解决方案:
能够创立两个输出对象
`Scanner in1=new Scanner(System.in);
Scanner in2=new Scanner(System.in);
Integer fistNum=in1.nextInt();
String fuhao=in2.nextLine();
Integer secondNum=in1.nextInt();`

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理