public class TRYCATCH8
{
public static void main(String args[])
{
try
{
try
{
System.out.println("1. Division by Zero");
int a=30/0;
System.out.println(a);
}
catch(ArithmeticException e)
{
System.out.println(e);
}
try
{
System.out.println("2. Array Index Out of Bound");
int b[]=new int[5];
b[7]=8;
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.println(e);
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
{
public static void main(String args[])
{
try
{
try
{
System.out.println("1. Division by Zero");
int a=30/0;
System.out.println(a);
}
catch(ArithmeticException e)
{
System.out.println(e);
}
try
{
System.out.println("2. Array Index Out of Bound");
int b[]=new int[5];
b[7]=8;
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.println(e);
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.