代码如下:
public class text {
public int devide(int x, int y) throws Exception {
if (y < 0)
throw new MyException("deisor is" + y);
int result = x / y;
return result;
}
}
class MyException extends Exception {
public MyException(String meg) {
super(meg);
}
}
class TestException {
public static void main(String[] args) {
try {
new text().devide(3, -1);
} catch (Exception e) {
System.out.println(e.getMessage());
}
System.out.println("program is running here!");
}
}