Difference between StringIndexOutOfBoundsException and ArrayIndexOutOfBoundsException in Java

Though both StringIndexOutOfBoundsException and ArrayIndexOutOfBoundsException are children of IndexOfBoundsException class, former is thrown by methods of String and related class (e.g. StringBuffer and StringBuilder) to indicate that an index is either negative or greater than the size of the String, or more general not valid. For example, charAt() method throws StringIndexOutOfBoundsException when an index is equal to the length of String? why? because String is backed by character array where index starts at 0 and ends at length -1. The ArrayIndexOutOfBoundsException is  also quite similar to former but thrown by code which deals with array access to indicate that array is accessed by invalid index. The index is either negative or greater than or equal to the length of the array.
Read more »