Friday 25 March 2016

Arithmetic Exception

Code:


class exception
{
    public static void main(String[] args)
    {
        int a=10,b=5,c=5;
        int x,y=0;
        try
        {
            x=a/(b-c);
        }
        catch(ArithmeticException e)
        {
            System.out.print("Divisible by zero");
            y=a/(b+c);
            System.out.print("\ny= "+y);
        }
    }
}


Output:


No comments:

Post a Comment