Java – Default Methods in Interfaces (Java 1.8+)

Default Methods: Allows interfaces to have concrete methods with default implementation.
Example:

interface Vehicle {
default void start() { System.out.println("Vehicle is starting."); }
}
class Car implements Vehicle {
}
Car myCar = new Car();
myCar.start();

No images available.