File size: 417 Bytes
c574d3a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
/**
* Let's see the solution of the Example-1 problem by a java try-catch block.
*/
public class TryCatchExample2 {
public static void main(String[] args) {
try {
int data = 50 / 0; // may throw exception
}
// handling the exception
catch (ArithmeticException e) {
System.out.println(e);
}
System.out.println("rest of the code");
}
} |