servlets struts hibernate jsf spring maven

Default methods in Java 8, and what it changes in API design

Java 8 introduced default methods in interfaces. what they are, and how they can change the design of APIs.

A nominal design

Earlier, in Java, interfaces could only have contracts – method signatures with no implementation. In order to add some implementation, a class was required, whether abstract or not. Hence, traditional API design then followed this hierarchy:

  • The root interface defines the contract
  • An intermediate class implements common behavior i.e. Bar
  • If necessary, a class in the hierarchy overrides this behavior e.g. Corge

javacodegeeks is optimized for learning.© javacodegeeks .
All Right Reserved and you agree to have read and accepted our term and condition