// StackTrace2 Example // Show how an ArrayIndexOutOfBoundsException // displays an error message and the stack // trace showing all of the method calls on // the system stack when the exception occurs. public class StackTrace1 { public static int[ ] a = {1, 2, 3, 4, 5}; public static void main(String[ ] args) { printResult( ); } public static void printResult( ) { int x = getValue(5); System.out.println(x); } public static int getValue(int v) { return a[v]; } }