public class Demo3 { public static void main(String[] args) { int[] a = new int[10]; // Index out of range try { if ( Math.random() < 0.5 ) a = null; // 50% chance a gets null... a[99] = 1; } catch (ArrayIndexOutOfBoundsException e) // TRY swapping order - Demo4 { System.out.println("(1)" + e); System.out.println("DONE"); } catch (Exception e) { System.out.println("(2)" + e); System.out.println("DONE"); } } }