3.1 Class Basics and Benefits

In Java, classes are composed of data and operations—or functions—that operate on the data. Objects of a class are created using the class as a template, or guide. Think of the class as a generic description, and an object as a specific item of that class. Or you can think of a class as a cookie cutter; the objects of that class are the cookies made with the cookie cutter. For example, a Student class might have the following data: name, year, and grade point average. All students have these three data items. We can create an object of the Student class by specifying an identifier for the object (for example, student1) along with a name, year, and grade point average for a particular student (for example, Maria ...

Get Java Illuminated, 5th 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.