public MyException(String msg){
super(msg);
}
}
static intΒ divide(int first,int second) throws MyException{
Β if(second==0)
Β throw new MyException(“can’t be divided by zero”);
return first/second;
Β }
Β try {
System.out.println(divide(4,0));
Β }
catch (MyException exc) {
exc.printStackTrace();
Β }
Β }
}





Leave a Reply