-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path_117_nested_try_catch.java
More file actions
28 lines (28 loc) · 1 KB
/
_117_nested_try_catch.java
File metadata and controls
28 lines (28 loc) · 1 KB
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
28
import java.util.Scanner;
public class _117_nested_try_catch {
public static void main(String[] args) {
int [] marks = new int[3];
marks[0] = 7;
marks[1] = 56;
marks[2] = 6;
Scanner sc = new Scanner(System.in);
boolean flag = true;
while(flag) {
System.out.println("Enter the value of index");
int ind = sc.nextInt();
try {
System.out.println("Welcome to video no 117");
try {
System.out.println(marks[ind]);
flag = false;
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("Sorry this index does not exist");
System.out.println("Exception in level 2");
}
} catch (Exception e) {
System.out.println("Exception in level 1");
}
}
System.out.println("Thanks for using this program");
}
}