How Object-Oriented Programming Works

You can think of the Java programs you create as objects, just like physical objects that exist in the real world. Objects exist independently of other objects, interact in specific ways, and can be combined with other objects to form something bigger. If you think of a computer program as a group of objects that interact with each other, you can design a program that’s more reliable, easier to understand, and reusable in other projects.

In Hour 23, “Creating Java2D Graphics,” you create a Java program that displays pie graphs—circles with different-colored pie slices to represent data (see Figure 10.1). A pie chart is an object that is made up of smaller objects—individual slices of different colors, a legend ...

Get Sams Teach Yourself Java™ in 24 Hours, Sixth 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.