1 public class SystemExitAndFinally 2 { 3 4 5 public static void main(String[] args) 6 7 { 8 9 try 10 { 11 12 13 System.out.println("in main"); 14 15 throw new Exception("Exception is thrown in main"); 16 17 //System.exit(0); 18 19 20 } 21 22 catch(Exception e) 23 24 { 25 26 System.out.println(e.getMessage()); 27 28 System.exit(0); 29 30 } 31 32 finally 33 34 { 35 36 System.out.println("in finally"); 37 38 } 39 40 } 41 42 43 }