接收值放在循环里边就可以一直输入,比如这样
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
System.out.println("Press any number to start counting");
int result=scanner.nextInt();
while (true){
System.out.println("enter your number:");
int z=scanner.nextInt();
if(z>result){
break;
}
System.out.println("the number is :"+z);
System.out.println("the max is :"+result);
}
}
1.你把input写进循环里面不就可以多次输入了吗
2.你写个while(true)死循环,然后写个if()break跳出循环,循环条件不一定非要写在while后面