Archives de catégorie : java

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 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

HashMap and ConcurrentHashMap Microbenchmark

Is ConcurrentHashMap always faster than HashMap for concurrent access ? If the map is accessible by concurrent threads, ConcurrentHashMap without additional synchronization mechanisms is often enough for reading operations. We may have some delay in the returned values by the … Continuer la lecture

Publié dans benchmark, java, map, microbenchmark, performance en JAVA | Marqué avec | 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

Overriding Object’s equals() method

  Plan The equals(Object) method : principles and simple example Brief definition of the equals() method  Default implementation of the equals() method and when override it The general contract to respect when we override the equals() method A simple example of … Continuer la lecture

Publié dans equals, java, Object, symmetry, transitivity | Laisser un commentaire

Implementing client-side the contact modification (8/9)

Go back to the table of contents for Developing a Contact Management Application with Angular 1.5X and Java Here are the tasks to implement the contact modification use case from the client side : Preview of the content that we want to get … Continuer la lecture

Publié dans Angular, AngularJS, Bootstrap, java, JavaScript, Spring Boot | Laisser un commentaire

Implementing client-side the contact deletion (7/9)

Go back to the table of contents for Developing a Contact Management Application with Angular 1.5X and Java Here are the tasks to implement the contact deletion use case from the client side : Preview of the content that we want to … Continuer la lecture

Publié dans Angular, AngularJS, Bootstrap, java, JavaScript, Spring Boot | Laisser un commentaire