Counting Matches on a Stream Filter 1. Overview In this tutorial, we’ll explore the use of the Stream.count() method. Specifically, we’ll see how we can combine the count() method with the filter() method to count the matches of a Predicate we’ve applied. 2. Using Stream.count() The count() method itself provides a… Continue Reading java-stream-filter-count

“Stream has already been operated upon or closed” Exception in Java 1. Overview In this brief article, we’re going to discuss a common Exception that we may encounter when working with the Stream class in Java 8: IllegalStateException: stream has already been operated upon or closed. We’ll discover the scenarios… Continue Reading java-stream-operated-upon-or-closed-exception

Guide to Stream.reduce() 1. Overview The Stream API provides a rich repertoire of intermediate, reduction, and terminal functions, which also support parallelization. More specifically, reduction stream operations allow us to produce one single result from a sequence of elements, by applying repeatedly a combining operation to the elements in the… Continue Reading java-stream-reduce