Java-Displaying Exception Description

Displaying Exception Description

You can display the description about the exception in a println( ) statement by simply passing the exception as an argument.

Program

2

Program Source

class Javaapp {

    public static void main(String[] args) {
        
        try{
           
            int a=1/0;
           
        }catch(ArithmeticException ex)
        {
            System.out.println("Exception : "+ex);
        }
        System.out.println("Execution Complete");
    }
}

Leave a Comment