问题相关代码,请勿粘贴截图
public class ceshi {
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
int a;
System.out.print("请输入一个整数:");
while(true)
{
try
{
a = scan.nextInt();
break;
} catch (Exception e) {
System.out.println("输入了不合法的整数,请重新输入:");
}
}
System.out.println("你输入的整数为:" + a);
}
}