62,614
社区成员
发帖
与我相关
我的任务
分享
public class MyException extends Exception {
private String message;
public MyException() {
super();
this.message = "输入为空或者不是数字";
}
public String getMessage() {
return message;
}
}
public class test10 {
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
if(true) {//true 为判断条件,满足条件手动抛出异常。
throw new MyException();
}
} catch (MyException e) {
// TODO Auto-generated catch block
System.out.println(e.getMessage());
}
}
}