Java 8 Articles

Collectors class in Java 8 to group and count elements in a list

How to use the Collectors class in Java 8 to group and count elements in a list?

In Java 8 and later versions, the Collectors class in the java.util.stream package provides various utility methods to perform reduction operations on streams. One of the powerful features of the Collectors class is the ability to group and count elements in a list or...
Optional Class in Java 8

How to use the Optional class in Java 8 to handle null values?

In Java 8 and later versions, the Optional class is part of the java.util package and provides a way to handle null values in an effective way and helps to avoid NullPointerExceptions. The Optional class lets you put a value that might be empty or null inside it. This...
Reduce method in Java 8

How to use the reduce() method in Java 8 to perform a calculation on a list of numbers?

In Java 8 and later versions, the reduce() method is available in the Stream API to perform a calculation on a list of numbers or any other elements. This method allows aggregating a stream's elements into a single result using a specified binary operator. This can be...
Convert List to Map using Streams - Java 8

Java 8 – How to convert List to Map?

In  this tutorial, we will see "How to convert List to Map using Java 8?"How to convert List to Map in java 8 [crayon-6605ba5cbfb9a618709542/]   Output: [crayon-6605ba5cbfb9e498820695/] How to...