Troubleshooting

One Off Index Error

The first item from the String is not being used or printed.

Remember that like other things in the Java language, the index for a String starts at zero, not one. As you can no doubt figure out, the last index of a String is length –1. This does not affect the actual length of the String. It remains at exactly the number of characters that are in the String.

Incorrect String Representation

When I print out an Object, I see something that looks like this: classname@8e41.

To get a better String representation for an object to print out, you must override the toString() method for the class you are trying to print. Otherwise, the default toString() method will be used that is defined on the Object class.

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.