Java Interface Demo — Using Default Methods

Quick Scroll Links:

Main.java
Sellable.java
MinionKeyFob.java

Java doc for package

This demo shows the use of default methods in interfaces.  The Sellable interface was originally developed with two abstract methods only.  (See GiftBasket.java.)  To add another (abstract) method to an existing interface would break all previous code that used it.  By having a default implementation of a new method, the problem is avoided, with few downsides.

View Java doc comments for this package