Skip to content

Commit 327cc5c

Browse files
exception handling multiple catch blocks
1 parent 27f6dc2 commit 327cc5c

1 file changed

+26
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
public class ExceptionHandlingUsingMultipleCatchBlock {
2+
public static void main(String args[])
3+
{
4+
int a[]={5,10};
5+
int b=5;
6+
try
7+
{
8+
int x=a[2]/b-a[1];
9+
}
10+
catch(ArithmeticException e)
11+
{
12+
System.out.println("ArithmeticException =>" + e.getMessage());
13+
}
14+
catch(ArrayIndexOutOfBoundsException e)
15+
{
16+
System.out.println("ArrayIndexOutOfBoundsException =>" +
17+
e.getMessage());
18+
}
19+
catch(ArrayStoreException e)
20+
{
21+
System.out.println("ArrayStoreException =>" + e.getMessage());
22+
}
23+
int y=a[1]/a[0];
24+
System.out.println("y= "+y);
25+
}
26+
}

0 commit comments

Comments
 (0)