9.4. Interfaces
An interface is a lot like an abstract class. The chief difference is that an interface cannot have any code in it. You might think of it as the class-level version of an abstract method. Remember that an abstract method is declared like this:
public abstract double getSpeed();
It just ends with a semicolon and no code. An interface is similar, and it has a usefulness like an abstract method's.
The real purpose of interfaces is to prevent multiple inheritance. Other programming languages, including C++, allow you to subclass from more than one immediate parent. It would be like writing this in Java:
public class A extends B, C ...
You don't need to do this in Java, and you cannot. You can inherit from more than one class, ...
Get Java™ for ColdFusion® Developers 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.