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

8次阅读

共计 296 个字符,预计需要花费 1 分钟才能阅读完成。

`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();`

正文完
 0