Archives de catégorie : java8

Java 8 flatMap or how to « flat mapped » a stream to another stream

Stream.map() and Stream.flatMap() methods are very close methods. These map a stream to another one by applying the function passed as argument for each element of the initial stream. But these are not applied in the same context. map() expects any … Continuer la lecture

Publié dans flatmap, java, java8, lambda | Laisser un commentaire

Java 8 Method references or how to shorten lambdas that invoke just one method

There are 3 categories of lambda expression that we could convert to method references. All of these consist of a single method invocation. 1) Invoking an instance method on the first argument of the lambda 2) Invoking a static method on … Continuer la lecture

Publié dans java, java 8, java8, lambda | Laisser un commentaire

Java 8 Lambda expressions or how to write a better quality code

Lambda that relies mainly on the Java 8 functional interface concept has two faces :– it is really necessary to use streams that were also introduced in Java 8– beyond this use with streams, it is also a excellent language … Continuer la lecture

Publié dans anonymous class, java, java 8, java8, lambda | Laisser un commentaire

Java 8 Predicates or how to parameterize a method with a boolean-valued function

Plan Before Java 8, we cannot pass a boolean-valued function/method as argument to another method : example of use case, consequences and workarounds How Java 8 addresses the need of passing a boolean-valued function/method as argument to another method ? We will … Continuer la lecture

Publié dans java, java 8, java8 | Un commentaire