Troubleshooting

IndexOutOfBoundsException

I get a runtime error reporting an IndexOutOfBoundsException when I call a collection method.

Java provides automatic bounds checking for collections just as it does for arrays. This exception means you have passed in invalid index value to a List. Remember that an index must be greater than or equal to zero and strictly less than the number of elements in the list.

NullPointerException

I get a runtime error reporting a NullPointerException when I call a Map method.

Support for null key and value objects in a Map is optional. A Map implementation that does not allow null values in one or the other throws a NullPointerException if you attempt to insert one.

UnsupportedOperationException

I get a runtime ...

Get Special Edition Using Java 2 Standard Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.