Java 8 – Convert List to Map
Few Java 8 examples to show you how to convert a List of objects into a Map, and how to handle the duplicated keys.
Favourite tutorials for developers
Few Java 8 examples to show you how to convert a List of objects into a Map, and how to handle the duplicated keys.
In this tutorial, we will show you few Java 8 examples to demonstrate the use of Streams filter(), collect(), findAny() and orElse()
In Java 8, BiPredicate is a functional interface, which accepts two arguments and returns a boolean, basically this BiPredicate is same with the Predicate, instead, it takes 2 arguments for…
In Java 8, Predicate is a functional interface, which accepts an argument and returns a boolean. Usually, it used to apply in a filter for a collection of objects.
In Java 8, Consumer is a functional interface; it takes an argument and returns nothing. It can act as Higher Order Function, so we can accepts Consumer as an argument,…
In Java 8, we can use the new forEach to loop or iterate a Map, List, Set, or Stream. Review the forEach method signature, it accepts a functional interface Consumer.…
If we use the NIO Files.delete to delete a non-empty directory in Java, it throws DirectoryNotEmptyException; for legacy IO File.delete to delete a non-empty directory, it returns a false. The…
In Java, we can use the Java 1.7 FileVisitor or Apache Commons IO FileUtils.copyDirectory to copy a directory, which includes its sub-directories and files. This article shows a few of…
This article shows how to Java 8 Files.walk to walk a file tree and stream operation filter to find files that match a specific file extension from a folder and…
In Java, we can use Files.write to create and write to a file. The Files.write also accepts an Iterable interface; it means this API can write a List to a…