[HD-OCP17/21-Fundamentals Pg 401, Sec. 15.2.2 - common-exceptions-that-are-usually-thrown-by-the-jvmexceptions-thrown-by
Posted: Sun Jan 05, 2025 8:17 pm
Error in page 436
Page 300
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
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
