Interfaces

An interface defines a contract: a set of methods that a class must provide, with no instance state. A class can implement several with implements. It can offer default methods with a body. Interfaces let you program against an abstraction and swap implementations.

Example

interface Payable {
    double montant();
}
class Facture implements Payable { public double montant() { return 10; } }

Related concepts

The whole glossary