Combining two or more Function functional interface

In this post, I will explain how to combine Function functional interfaces. They are two ways in which we can combine Function functional interface and it is achieved using two methods in Function interface as mentioned below 1) default <V> Function<T,V> andThen(Function<? super R,? extends V> after) 2) default <V> Function<V,R> compose(Function<? super V,? extends…… Continue reading Combining two or more Function functional interface

Function functional interface

In this post, with an example I will show how to use Function functional interface. Function interface is a functional interface that takes an input and produces an output. This is achieved by its “apply” method. Below is an example Main Code 1 package function; 2 3 import java.util.ArrayList; 4 import java.util.List; 5 import java.util.function.Function;…… Continue reading Function functional interface

Combining two or more Consumer Functional Interface

In this post I will explain how to combine two or more Consumer Functional interface implementations. Consumer Functional interface has a default method “andThen”, which combines two Consumer Functional interface implementations. The method signature is as shown below default Consumer andThen(Consumer after) The way two Consumer implementations are combined using “andThen” method is as shown…… Continue reading Combining two or more Consumer Functional Interface

Creating a temporary file and directory

The post shows you how to create a temporary file and directory in java with an example. Main Code 1 package nio; 2 3 import java.io.IOException; 4 import java.nio.file.Files; 5 import java.nio.file.Path; 6 import java.nio.file.Paths; 7 8 public class Example1 { 9 public static void main(String[] args) throws IOException { 10 Path path = Files.createTempFile(“prefix”,…… Continue reading Creating a temporary file and directory