Write a Java program to demonstrate the use of try-catch block.
public class TryCatch1 {
public static void main(String[] args) {
try {
int data=50/0;//may throw exception
}
catch (ArithmeticException a) {
a.printStackTrace();
}
System.out.println("rest of the code...");
}
}
java.lang.ArithmeticException: / by zero
at exception.TryCatch1.main(TryCatch1.java:8)
rest of the code...