Java Program to demonstrate the use of try-catch block

Write a Java program to demonstrate the use of try-catch block.



Source Code
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...");  
	}

}
Output
java.lang.ArithmeticException: / by zero
	at exception.TryCatch1.main(TryCatch1.java:8)
rest of the code...