An interface is a collection of method names, without definitions, that can be added to classes to provide additional behavior not included with those methods the class defined itself or inherited from its superclasses.

The problem with multiple inheritance is that it makes a programming language far more complex to learn, to use, and to implement.

A Java interface is a collection of abstract behavior that can be mixed into any class to add to that class behavior that is not supplied by its superclasses. Specifically, a Java interface contains nothing but abstract method definitions and constants-no instance variables and no method implementations.

Interfaces are implemented and used throughout the Java class library whenever a behavior is expected to be implemented by a number of disparate classes.

The Java class hierarchy, for example, defines and uses the interfaces java.lang.Runnable

java.awt.image.ImageConsumer, and java.awt.image.ImageProducer.

Scroll to Top