package dummyarti;
public class ExceptionHandling {
//declare Class Variables
int e1=5 ;
int f1=0 ;
public void test() {
try {
int c = e1 / f1; //creating exception
}
catch (ArithmeticException e2) {
System.out.println("Inside Catch Block"); //handling exception
System.out.println(e2.getMessage());
}
catch (Exception e) {
System.out.println(e.getMessage());
}
finally{
System.out.println("Executing Finally"); // will execute in any case
}
}
public static void main(String[]args) {
ExceptionHandling eh=new ExceptionHandling();
eh.test();
}
}
public class ExceptionHandling {
//declare Class Variables
int e1=5 ;
int f1=0 ;
public void test() {
try {
int c = e1 / f1; //creating exception
}
catch (ArithmeticException e2) {
System.out.println("Inside Catch Block"); //handling exception
System.out.println(e2.getMessage());
}
catch (Exception e) {
System.out.println(e.getMessage());
}
finally{
System.out.println("Executing Finally"); // will execute in any case
}
}
public static void main(String[]args) {
ExceptionHandling eh=new ExceptionHandling();
eh.test();
}
}
No comments:
Post a Comment