Blog Articles

Find First Non-Repeated Character in a String - Java 8

Find the first non-repeating character in a string using Java 8

In this tutorial, we will learn "Find the first non-repeating character in a string using Java 8?". In order to do that, we are going to leverage the Stream API along with the Collectors.groupingBy collector. Find the first non-repeated character in a string using...
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...