Skip to content

Commit 48f6034

Browse files
authored
Create FinallyExample.java
1 parent ded2956 commit 48f6034

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
public class FinallyExample {
2+
3+
public static void main(String[] args) {
4+
try {
5+
int result = 10 / 0; // This will throw an ArithmeticException
6+
} catch (ArithmeticException e) {
7+
System.out.println("Caught ArithmeticException: " + e.getMessage());
8+
} finally {
9+
System.out.println("This block always executes, regardless of exception.");
10+
}
11+
}
12+
}

0 commit comments

Comments
 (0)