Java 9 Private Interface Method » grokonez

Java 9 Private Interface Method » grokonez

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.

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

java java9 interface-method

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How to Install OpenJDK 11 on CentOS 8

What is OpenJDK? OpenJDk or Open Java Development Kit is a free, open-source framework of the Java Platform, Standard Edition (or Java SE).

Going Beyond Java 8: Local Variable Type Inference (var) - DZone Java

In this article, we will talk about the most important new feature introduced with Java 10, officially called local variable type inference. An extremely important function in java. You will regret skipping this article.

Java Map Interface Example | Map Interface in Java

Java Map interface is an object that is designed to store associations between keys and their corresponding values or key/value pairs.

Deque Interface In Java Example | Java Deque Interface

Java Deque interface is related to a data structure known as a queue. It is mainly known as the double-ended queue, which supports the addition or removal of data from either end.

Java Queue Interface Example | Queue Interface in Java

Java Queue is a data structure we can insert an element at that end of a queue and remove it from at the beginning of the queue.