Chapter 6

Using the Object and Class Classes

In This Chapter

arrow Using the toString method

arrow Implementing the equals method

arrow Trying out the clone method

arrow Understanding the Class class

In this chapter, you find out how to use two classes of the Java API that are important to object-oriented programming:

  • The Object class, which every other class inherits — including all the classes in the Java API and any classes you create yourself
  • The Class class, which is used to get information about an object's type

technicalstuff.eps If I could, I'd plant a huge Technical Stuff icon on this entire chapter. All this stuff is a bit on the technical side, and many Java programmers get by for years without understanding or using it. Still, I recommend that you read this chapter carefully. Even if it all doesn't sink in, it may help explain why some things in Java don't work quite the way you think they should, and the information in this chapter may someday help you program your way out of a difficult corner.

The Mother ...

Get Java All-in-One For Dummies, 4th 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.