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 comment