June 2018
Intermediate to advanced
280 pages
7h 46m
English
Java 8 allowed us to add default and static methods to interfaces, where you were required to implement only unimplemented methods in the interface. Now, as we are allowed to add default implementations, it may be possible that we want to break our code into modules or pull out common code in a method that can be used by other functions. But we do not want to expose this common method. To solve this, Java 9 has allowed private methods in interfaces.
The following code shows a perfectly valid implementation of an interface in Java 9, which has a helper private method used by a default method:
package com.example;/*** An Interface to showcase that private methods are allowed**/public interface InterfaceExample ...
Read now
Unlock full access