O'Reilly logo

Just Java™ 2 by Peter van der Linden

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

What Is an Object?

The previous section focused on classes and ended with a small but complete user-defined class called Timestamp. We've already let the cat out of the bag that an object is a variable of a class type, not a primitive type. There are several other ways to say that:

  • An object is an instance of a class

  • An object belongs to a class

  • An object belongs to a reference type

However, they all mean the same thing. This section fills in some more of the details on objects: how you declare them and how you create them (two different things), and how you use them.

What “reference type” really means

An object declaration looks exactly the same as a primitive variable declaration. You first write the type name (which is the class ...

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