Class PrivateInterfaceMethodExamples
java.lang.Object
net.jrodolfo.java_evolution.java09.PrivateInterfaceMethodExamples
Demonstrates private methods in interfaces, introduced in Java 9.
Java 8 introduced default methods, which allowed interfaces to provide behavior. The missing piece was private helper logic: without Java 9, common code shared by multiple default methods had to be duplicated or exposed as a public interface method.
Java 9 solved this by allowing private and private static methods in interfaces. Default methods can now share implementation details without adding those helpers to the public API.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classEmpty implementation that receives behavior from interface default methods.static interfaceInterface with default methods that share private helper logic. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates a formatter that inherits default methods using private interface helpers.
-
Constructor Details
-
PrivateInterfaceMethodExamples
public PrivateInterfaceMethodExamples()
-
-
Method Details
-
formatter
Creates a formatter that inherits default methods using private interface helpers.- Returns:
- a formatter implementation
-