map() method of Optional object in Java

This method first will check whether our Optional object is empty or not? If not empty, convert its value to another value. Similar to the filter() method, this method returns an Optional object with a value after conversion. For example:

In the above example,… Read More

Learn about Supplier Functional Interface in Java

Supplier is a Functional Interface, so it only contains an abstract method as follows:

This interface simply returns the value in the context that is being used by the get() method. For example, we have the following list:

Now that I want to… Read More

Learn about Consumer Functional Interface in Java

Java 8 introduces a new package containing Functional Interfaces called java.util.function. In this package, we have many interfaces like Consumer, Supplier, Predicate, … In this tutorial, we will learn about Consumer Functional Interface. The content of this interface is as follows:

Because the Consumer… Read More