Chapter 8. Interfaces

Interfaces

Interfaces are an important concept in Java. In this chapter we’ll explain how you use interfaces and how they work. We’ll start by describing the problem that they solve.

What Problem Does an Interface Solve?

We’ve seen in previous chapters how classes can be related in a hierarchy, with the common behavior higher up the tree. An example is given in Figure 8-1.

Where should the refuel() method go?

Figure 8-1. Where should the refuel() ...

Get Just Java™ 2, Fifth 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.