Try & Catch

Using Try & Catch


class Catch
{
    public static void main(String ar[])
    {
        int d,a;
        try
        {
            d=0;
            a=42/d;

            System.out.println("This Will Not Be Printed");
        }
        catch (ArithmeticException e)
        {
            System.out.println("Division By Zero.");
        }
        System.out.println("After Catch Statment");
    }
}
        

Output: