Built-in Exceptions
The Java programming language comes with many exceptions built into the language. These cover many different types of common, unfortunate situations. For example, ArrayIndex-OutOfBoundsException is popular. It is thrown to indicate that you have attempted to access an index that does not exist in an array. The system will throw this exception if you have an array of 4 elements, and you type x = myArray[100] (no 100th element). Or if you type x = myArray[-1] (cannot be negative value). Or if you type x = myArray[4] (there are only elements 0-3 in a four element array). This is a good example of the kind of thing that can happen easily, but from which it also should be easy to recover.
UncheckedExceptions
The ArrayIndexOutOfBoundsException ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access