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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.