Java SE 8/11 Programmer II Exam Series: Advanced Stream Pipeline Concepts

Introduction In this section, we will cover advanced stream pipeline concepts in Java 8. We will analyze chaining Optionals, predefined collectors, and learn how to use groupingBy, partitioningBy, and mapping methods. Chaining Optionals Chaining optionals help eliminate the nested if-statements for Optional variables. The function below prints the virus name if it contains Covid-19 without […]

Java SE 8/11 Programmer II Exam Series: Primitive Streams

Introduction In this post, we will cover creating primitive streams, using Optional types with primitives, and summarizing statistics in a single pass. Primitive Streams There are three types of primitive streams: IntStream (int, short, byte, and char), LongStream (long), and DoubleStream (double and float). Creating Primitive Streams Creating primitive streams is the same as a […]

Java SE 8/11 Programmer II Exam Series: Streams

Introduction In this post, we will cover the streams in Java 8. We will discover the three parts of the pipeline: source, terminal, and intermediate operations. What is a stream pipeline? Stream operations are divided into intermediate and terminal operations and are combined to form stream pipelines. A stream pipeline consists of a source; followed by zero or more intermediate […]

Item 45: Use streams judiciously

Introduction Streams in Java 8 support functional-style operations on streams of elements. This API makes it easier to perform bulk operations, sequentially or in parallel. When used appropriately, streams can make programs shorter and clearer. When used inappropriately, they can make programs difficult to read and maintain. When to use streams? Streams are a good […]