public class Exception1 // simple example to demonstrate the use of try/catch blocks { public static void main(String[] args) { int x=5, y=0, z; try{ // we will try to do a division but if the division causes an ArithmeticException (usually division by zero), it gets z=x/y; // thrown to the corresponding catch block (if one exists) } catch(ArithmeticException e) // catch an ArithmeticException here thrown by the division { System.out.println("Arithmetic Exception Raised, cannot continue"); // instead of outputting e, we are outputting our own message, we could also } // to System.out.println(e) or System.out.println(e + " ..."); } }