10.10.1 default Interface Methods
Prior to Java SE 8, interface methods could be only public abstract
methods. This meant that an interface specified what operations an implementing class must perform but not how the class should perform them.
In Java SE 8, interfaces also may contain public
default methods with concrete default implementations that specify how operations are performed when an implementing class does not override the methods. If a class implements such an interface, the class also receives the interface’s default
implementations (if any). To declare a default
method, place the keyword default
before the method’s return type and provide a concrete method implementation.
Adding Methods to Existing Interfaces
Prior to Java SE ...
Get Java™ How To Program (Early Objects), Tenth Edition 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.