Java 8 | Eklavya Online

Java 8

Java 8 features

Important features of java 8 are: forEach() method in Iterable interface default and static methods in Interfaces Interface Changes Functional Interfaces and Lambda Expressions Java Stream API for Bulk Data Operations on Collections Java Time API Collection API improvements Concurrency API improvements Java IO improvements Miscellaneous Core API improvements forEach() method in Iterable interface Whenever …

Java 8 features Read More »

Java 8 stream and lambda function important examples

To Understand example please follow main method of StreamAPI class import java.util.ArrayList;import java.util.Date;import java.util.List;import java.util.Map;import java.util.Set;import java.util.stream.Collectors; public class StreamAPI {    public static void main(String[] args) {      List list = new ArrayList<>();       list.add(new CheckDomain(100l,”GOC1″,new Date()));      list.add(new CheckDomain(100l,”GOC1″,new Date()));      list.add(new CheckDomain(101l,”GOC2″,new Date()));      list.add(new CheckDomain(101l,”GOC2″,new …

Java 8 stream and lambda function important examples Read More »

Java 8 Lambda functions complete tutorial with Examples

Java Lambda Expressions In this article, we will learn about Java lambda expression and the use of lambda expression with functional interfaces, generic functional interface, and stream API with the help of examples.l The lambda expression was introduced first time in Java 8. Its main objective to increase the expressive power of the language. But, …

Java 8 Lambda functions complete tutorial with Examples Read More »

Java 8 interview questions and answers

What are new features which got introduced in Java 8? What are main advantages of using Java 8? What is lambda expression? Can you explain the syntax of Lambda expression? What are functional interfaces? How lambda expression and functional interfaces are related? Can you create your own functional interface? What is method reference in java …

Java 8 interview questions and answers Read More »

Java 8 Predicate examples

Predicate is single argument functional interface which returns true or false. It takes one argument and returns result in form of true or false.        // Using anonymous class        Predicate<Integer> predicate=new Predicate<Integer>() {              @Override            public boolean test(Integer i) {                 return i > 100;            }        };         // Using lambda expression        Predicate<Integer> predicate = i -> i > 100;  Here is the definition of Predicate interface. package java.util.function; import …

Java 8 Predicate examples Read More »

Java 8 Consumer examples

Consumer definition Consumer takes single argument and do not return any result.Here is the definition of Consumer interface. @FunctionalInterfacepublicinterface Consumer<T> {/*** * Performs this operation on the given argument. * * @param t the input* argument*/void accept(T t); default Consumer<T> andThen(Consumer<? super T> after) {Objects.requireNonNull(after);return (T t) -> {accept(t);after.accept(t);};}} It has a functional method called accept() and default methodandThen(). Consumer …

Java 8 Consumer examples Read More »

Java 8 Supplier examples

In this post, we are going to see about java 8 Supplier interface.Supplier is functional interface which does not take any argument and produces result of type T.It has a functional method called T get() As Supplier is functional interface, so it can be used as assignment target for lambda expressions. Here is source code of Java 8 supplier interface. package java.util.function;/*** Represents a …

Java 8 Supplier examples Read More »