请问这个自定义异常的错误是什么?
class MyException extends Exception{public static void main(String[] args)
{
int id = 0;
MyException(String message,int id){
super(message);
this.id = id;
}
int getId(){
return id;
}
}
}
public class TestMyException{
public void regist(int num) throws MyException{
if(num < 0){
throw new MyException("人数为负数,不合理",3);
}
System.out.println("登记人数"+ num);
}
public void manager(){
try{
regist(100);
} catch (MyException e)
{
System.out.println("登记失败,出错类型码=" + e.getId());
e.printStackTrace();
}
System.out.println("操作结束");
}
public static void main(String[] args){
TestMyException t = new TestException();
t.manager();
}
}