Java interfaces

In Java, an interface is a "blueprint" that defines what is common to some group of classes. Typically:

  • an interface defines a series of method signatures (the one-line "definitions" of methods) but doesn't say how those methods are implemented;
  • then, individual classes provide implementations of those methods;
  • those classes can say that they implement the interface in question.

There are also some more marginal cases that we'll look at later.

To illustrate more fully what an interface is, we'll look at an actual example from the JDK: the Appendable interface.


Written by Neil Coffey. Copyright © Javamex UK 2008. All rights reserved.