79 Program on how to Print all Exceptions which are Raised in our Application in Java?

Code:

class Demo
{
public static void main( String args[] )
{
try
{
System.out.println(" try block ");
int a = 10/0;
}
catch(Exception e)
{
System.out.println(" catch block ");
System.out.println( e.toString() );

try
{
System.out.println("ram".charAt(3));
}
catch( Exception e1)
{
System.out.println(e1.toString() );
}
}
finally
{
System.out.println("  finally block ");

try
{
int b[] = new int[-1];
}
catch( Exception e1)
{
System.out.println(e1.toString() );
}
}
}
}



Output:




Previous
Next Post »