Relating Objects to Java Classes

So far, the term object has been treated somewhat generically and it has been used a little loosely when referring to the code examples. Now classes need to be brought into the discussion to make it more concrete with respect to Java. Object data types are defined in Java using classes, like the Car class shown previously. In the software realm, objects are instances of those classes.

A class can be thought of as a template for creating an object. In the car example, SaturnSL2 is a class, not an object. It is a template for creating car objects that are of that type (a particular make and model in this case). If you go to a car dealership and ask to see a Saturn SL2, you are using a type (the class) to describe ...

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.