How to Handle Exception In Java

1.
public class simple_example {

public static void main(String[] args) {
int i=10;
int j=0;
try {
System.out.println(“i/j=”+i/j);
} catch (Exception e) {
//System.out.println(e);
System.out.println(“number divide by zero”);
}

}
}

Output:
number divide by zero

Leave a Reply

Your email address will not be published. Required fields are marked *

8 + 1 =