public class ExceptionTest {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
try {
System.out.println("你的选择是:A,B,C,D");
String s=sc.next();
if(s=="a"){
System.out.println("选择正确");
}
else{
System.out.println("选择错误");
}
} catch (InputMismatchException e) {
System.out.println("请重新输入");
}
}
}
相关分类