Interface
An interface is a contract that defines a set of methods a class must provide, without saying how they work. A class that implements the interface must supply the body for each of those methods.
Interfaces let different classes be used through the same type, which supports polymorphism and loose coupling: code can depend on the interface rather than a specific class. In Java a class can implement many interfaces, even though it can extend only one class.
interface Printable {
void print();
}
class Invoice implements Printable {
public void print() { System.out.println("Printing invoice"); }
}
Printable p = new Invoice();
p.print();