Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
while(true){
System.out.println(n);
}这代码输入1 输出为 一个1 (且程序不断运行)
Scanner sc=new Scanner(System.in);
int n;
while(true){
n=sc.nextInt();
System.out.println(n);
}这代码输入1 后 不断输出1,(且程序不断运行)
为什么会这样,都应该不断输出1的吗。谢谢
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4741/viewspace-3150305/ ,如需转载,请注明出处,否则将追究法律责任。