
372 CHAPTER 7 Object-Oriented Programming,Part 2: User-Defined Classes
Introduction
When you see the title of this chapter, you might say, “Finally, we get to
write our own classes.” Actually, we’ve been writing classes all along. All
Java source code belongs to a class. The classes we’ve been writing are
application and applet classes. Now it’s time to write some service classes—
classes that encapsulate data and methods for use by applications, applets,
or even other service classes. These are called user-defined classes because
we, rather than the Java authors, create them.
First, let’s take a moment to examine why we want to create user-
defined