62,620
社区成员
发帖
与我相关
我的任务
分享
public class test10 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input=new Scanner(System.in);
boolean flag = true;
int x;
int y;
while (flag) {
try {
System.out.print("输入X值:");
x = input.nextInt();
System.out.print("输入Y值:");
y = input.nextInt();
flag = false;
} catch (InputMismatchException e) {
System.out.println("输入数超出范围,请重新输入");
input.next();
}
}
}
}
运行结果:
输入X值:aaa
输入数超出范围,请重新输入
输入X值: