如果输入不是整数,我正在尝试使用 while 循环要求用户重新输入
例如。输入是任何浮点数或字符串
int input;
Scanner scan = new Scanner (System.in);
System.out.print ("Enter the number of miles: ");
input = scan.nextInt();
while (input == int) // This is where the problem is
{
System.out.print("Invalid input. Please reenter: ");
input = scan.nextInt();
}
我想不出办法来做到这一点。我刚刚被介绍给java