(String[] args)
| 3 | public class NestedTry { |
| 4 | |
| 5 | public static void main(String[] args) { |
| 6 | int a = 20, b; |
| 7 | int ch[] = new int[20]; |
| 8 | try { |
| 9 | b = a/0; |
| 10 | try { |
| 11 | System.out.println("Value of b = " + b); |
| 12 | } |
| 13 | catch(Exception e) { |
| 14 | System.out.println("Inner block Exception occured!"); |
| 15 | } |
| 16 | } |
| 17 | catch(Exception e) { |
| 18 | System.out.println("Outer block exception occured!"); |
| 19 | } |
| 20 | finally { |
| 21 | System.out.println("Quit"); |
| 22 | System.out.println("This block will always execute!"); |
| 23 | } |
| 24 | // finally block can be used to catch any exception |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | /* Note: Inner catch will use the outer catch block but outer catch will not use inner catch block exception |
nothing calls this directly
no outgoing calls
no test coverage detected