Chapter 11. Interfaces

  • What Problem Does an Interface Solve?

  • Interface java.lang.Comparable

  • Interfaces Versus Abstract Classes

  • Granting Permission Through an Interface—Cloneable

  • What Protected Really Means

  • Using Interface Callbacks for GUI Event Handlers

  • The Class Double

  • Exercises

  • Some Light Relief—The Java-Powered Toaster

Interfaces are an important concept in Java. In this chapter, we'll explain what interfaces do, and how you use them. Here's a summary of what interfaces do, so you can see where we're headed.

In a few words, an interface is similar to a class that only abstract methods. You can't instantiate an abstract class; its purpose is to force any subclasses to implement its methods. That allows other classes to rely ...

Get Just Java™ 2 now with O’Reilly online learning.

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