Google Ads

Thursday, May 21, 2009

MULTI CATCH STMT IN TRY BLOCK

class multicatch
{
public static void main(String[]args)
{
try
{
int a=args.length;
System.out.println("a="+a);
int b=42/a;
int c[]= {1};
c[42]=99;
}
catch(ArithmeticException e)
{
System.out.println("DIVIDE BY 0:"+e);
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.println("ARRAY INDEX OUT OF BOUND:"+e);
}
System.out.println("after try or catch block:");
}
}



OUTPUT

Z:\jdk1.4\bin>

Z:\jdk1.4\bin>javac multicatch.java


Z:\jdk1.4\bin>java multicatch

DIVIDE BY 0:java.lang.ArithmeticException: / by zero

after try or catch block:


Z:\jdk1.4\bin>

No comments:

Post a Comment