- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnestedtrycatch.java
More file actions
Latest commit
17 lines (15 loc) · 647 Bytes
/
Copy pathnestedtrycatch.java
File metadata and controls
17 lines (15 loc) · 647 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
publicclassnestedtrycatch{
publicstaticvoidmain(String[] args) {
try {
int[] arr = {1, 2, 3};
System.out.println(arr[10]); // This line will cause an IndexOutOfBoundsException
try {
intnum = Integer.parseInt("abc"); // This line will cause a NumberFormatException
} catch (NumberFormatExceptione) {
System.out.println("Inner catch block: NumberFormatException occurred");
}
} catch (IndexOutOfBoundsExceptione) {
System.out.println("Outer catch block: ArrayIndexOutOfBoundsException occurred");
}
}
}