Code: Select all
int[] ia = new int[]{ 1, 2, 3}; // ia is of length 3
System.out.println(ia[-1]); //ArrayIndexOutOfBoundsException
System.out.println(ia[3]); //ArrayIndexOutOfBoundsException
System.out.println("0123".charAt(4)); //StringIndexOutOfBoundsException
char charAt(int index) - Returns the char value at the specified index. Throws IndexOutOfBoundsException if the index argument is negative or is not less than the length of this string.
Java doc says charAt throws IndexOutOfBoundsException
