在下面的代码中InputMismatchException
,甚至在我给出输入之前,我就已经到达了第 80 行。为什么是这样?
try {
loop:while(true)
{
choice=sc.nextInt();
switch (choice) {
case 1:
term=3;
break loop;
case 2:
term=6;
break loop;
default:
System.out.println("Invalid Input.. Enter again");
choice=sc.nextInt();
}
}
}
catch (InputMismatchException e2) {
System.out.println("Wrong Format!! Enter a number");
choice=sc.nextInt(); //line 80
}