O'Reilly logo

Java Garage by Eben Hewitt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required