Category: Java

Lambda in Java8 0

Lambda in Java8

A lambda expression is a concise representation of anonymous function that can be passed around. It has following characteristics: Anonymous: It does not have a name like we have in method Function: We call...

CompletableFuture in Java 8 0

CompletableFuture in Java 8

In this we will first discuss what is the benefit of completablefuture of Java 8 over Future CompletableFuture was introduced to remove the limitation of Future Object in Java 8, lets first see what...

Optional in Java 8 1

Optional in Java 8

Optional was introduced in Java 8 to handle null references and NullPointerException. Null references to Object has many issues few of which I have listed below: Its a source of error, Null reference lead...

Streams in Java 8 0

Streams in Java 8

Streams is a sequence of elements from a source that support data processing operations. You can think of them as Iterators over collection of data. Stream Characteristics: Sequence of elements: Like a collection, a...

Function Interface 0

Function Interface

The java.util.function.Function Interface is a Functional Interface which has apply as abstract method, It takes T object as the Input argument and returns an object of type R . Usage: we can use it...

Consumer Interface 0

Consumer Interface

The java.util.function.Consumer<T> interface has 1 abstract method accept that takes object of generic type T and returns no result(void). Usage:  You can use this Interface where you want to perform some operation on an object...

Predicate 0

Predicate

The java.util.function.Predicate<T> Interface has one abstract method named test that accepts an object of generic type T and returns a boolean Usage: It can be used to represent a boolean expression that uses object...

Quiz 0

Quiz

Which of the following is valid use case of lambda expression 1.execute(() -> {}); public void execute(Runnable r){ r.run(); } 2.public Callable fetch() { return () -> “Hey”; } 3.Predicate p = (Employee a)...

Functional Interfaces 0

Functional Interfaces

Functional Interfaces are interfaces which have only one abstract method. There are many functional interfaces in Java API like here I have mentioned few examples: Functional interfaces can also have default methods,Default methods are...

Java 8 Features with Examples 0

Java 8 Features with Examples

Lambda Expression: Its a concise representation of an anonymous function that can be passed around, it has below mentioned properties. Anonymous : It does not have a explicit name like a method Function: We...