Saturday 7 February 2015

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


No comments:

Post a Comment