Comparator example Java 8 Lambda expression

We’ll show you how to write a Comparator to sort a List using Java 8 Lambda expressions in this example. Classic Comparator example Lambda expression equivalent. Sort without Lambda A comparison of Developer objects based on their age is an example. Normally, you use Collections.sort and pass an anonymous Comparator class like this : Output […]

How to convert List to int[] in Java ?

List<Integer> to int[] To convert List<Integer> to int[] in java we can use les Streams, With Java 8, int[] can be converted to Integer[] easily : Integer[] is generally not a good map key, as others have said. However, we now have a reasonably clean and native code in terms of conversion. Also read , […]

forEach Java 8 Examples

To loop or iterate a Map, List, Set, or Stream in Java 8, we can use the new forEach method. Loop a Map 1,1 A standard method for looping a Map is shown below. 1.2 We can use forEach in Java 8 to loop through a Map and print out its entries. Output 1.3 The […]

Consumer Java 8 Examples, how to use ?

In Java 8, Consumer is a functional interface, it takes an argument and returns nothing. An interface with just one abstract method is referred to as a functional interface. They are limited to displaying only one type of feature. Lambda expressions can be used to describe a functional interface instance starting with Java 8. Some examples of […]

Writing Nashorn Command-Line Scripts with Nake

Nake is a simplified version of Make (Cake, Jake, Rake) for Java 8 based on the Nashorn Javascript Engine. I wrote Nake to automate common tasks in our daily project business here at Pondus. You define tasks in a project-specific Nakefile and call those tasks from the command line. Tasks are written in Javascript empowered […]

Patterns optionels

Patterns optionels : De nombreuses choses ont été introduites en Java 8 qui changent la façon de concevoir les applications et les API. Les lambdas bien sûr, l’API Stream également. Si tu es un habitué de ce blog, cher et précieux lecteur, tu es déjà au courant. Patterns optionels : Un autre élément a été […]