public class ExceptionTest2 { public static void main(String[] args) { try { for (int i=1; i<10; i++) System.out.println(args[i]); } catch (ArrayIndexOutOfBoundsException iob) { System.out.println("Got exception : " + iob ); iob.printStackTrace(); } catch (Exception e) { // not needed here, but just wanted to show you System.out.println("Any other exceptions would go here"); } finally { System.out.println("This is always called"); } } }