In this recipe, you will learn about a new feature that was introduced in Java 9, the private interface method, which is of two types—static and non-static.
Creating interfaces with private methods
Getting ready
A private interface method must have an implementation (a body with a code). A private interface method not used by other methods of the same interface does not make sense. The purpose of a private method is to contain functionality that is common between two or more methods with a body in the same interface or to isolate a section of code in a separate method for better structure and readability. A private interface method cannot be overridden—not by a method of any other interface, nor by a method in...