Starting from Java 8, a method which is defined in an interface can have a default implementation:
For example:
interface Descriptive {
default String desc() {
return "fantastic";
}
}
class Item implements Descriptive {
// the method "desc" is not implemented here
}
Item item = new Item();
item.desc(); // "fantastic"
class Book implements Descriptive {
@Override
public String desc() {
return "Cool book!";
}
}
Book book = new Book();
book.desc(); // "Cool book!"