-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExceptionEg.java
More file actions
27 lines (27 loc) · 808 Bytes
/
ExceptionEg.java
File metadata and controls
27 lines (27 loc) · 808 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import java.util.Scanner;
public class ExceptionEg{
public static void main (String args[])
{ int sq = 0;
Scanner scanner = new Scanner(System.in);
int num=scanner.nextInt();
for(int i=1; i<=num; i++)
{
sq+=num;
}
System.out.println(sq);
try{
System.out.println(2/0);
System.out.println("After Exception");
}
catch(ArithmeticException ae){
System.out.println("Not Divides "+ae.getMessage());
}
catch(ArrayIndexOutOfBoundsException aioube){
System.out.println("Not in Bound "+aioube.getMessage());
}
// System.out.println("After Exception");//Not Possible
finally{
System.out.println("Finally");
}
}
}