public class XTException extends Exception {
public XTException(String msg){
super(msg);
}
}
public class Demo {
public int div(int a,int b) throws XTException{
int c = a/b;
return c;
}
}
public class Test {
public static void main(String[] args) {
Demo d = new Demo();
try {
System.out.println(d.div(10, 0));
} catch (XTException e) {
e.printStackTrace();
}
System.out.println("为什么不可以输出这句话?");
}
}