Archives de catégorie : java 8

Comparator : how to implement it

Plan Model to illustrate Way to never use  Way acceptable only for Java 6 and below Favor methods of built-in basic type Comparable implementations in Java 7 Favor Comparator construction methods in Java 8 This post is inspired by the … Continuer la lecture

Publié dans java, java 8 | Laisser un commentaire

Java 8 collecting inside a FlatMap : some limitations

Stream.map() and Stream.flatMap() methods are very close methods as discussed here. Here we will discuss about Stream.flatMap() limitations . We can broadly identify two usages of Stream.flatMap(): – flattening a nested stream within the initial stream to perform the main collect operation on … Continuer la lecture

Publié dans java, java 8, java 9, Non classé | 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