dev-resources.site
for different kinds of informations.
Java 9 Private Interface Method
Published at
4/28/2021
Categories
java9
java
interface
Author
loizenai
Author
8 person written this
loizenai
open
https://grokonez.com/java/java-9/java-9-private-interface-method
Java 9 Private Interface Method
In this article, we're gonna take a look at Java 9 Private Interface Method which helps us avoid duplicate code and keep encapsulation for interface.
1. Java 8 - Interface
Java 8 provides 2 new features for Interface: default methods and static methods.
This is an example of Java 8 interface:
public interface ICustomerService {
default void healthcare(String name) {
System.out.println(name + " registers for customer service.");
System.out.println("-- get HealthCare Service.");
}
default void consult(String name) {
System.out.println(name + " registers for customer service.");
System.out.println("-- get Consultation Service.");
}
}
To make code easy to read and clear, we can create new register()
method inside:
More at:
https://grokonez.com/java/java-9/java-9-private-interface-method
Java 9 Private Interface Method
java9 Article's
12 articles in total
Java 9 Module System
read article
Java 9 Multi-Resolution Images
read article
Java 9 Optional Improvements
read article
Java 9 TIFF Image I/O plugins
read article
Java 9 Private Interface Method
currently reading
Java 9 Flow API example – Publisher and Subscriber
read article
Java 9 Factory Method for Collections: List, Set, Map
read article
Java 9 Tutorial
read article
Java 9 Flow API – Reactive Streams
read article
Java 9 CompletableFuture API Improvements - Delay and Timeout Support
read article
Optional to stream in java 9
read article
Java 8 Vs. Java 9: Get Ready for a New Era
read article
Featured ones: