Iterable to Stream in Java

2021 VietMX 0

1. Overview In this short tutorial, let’s convert a Java Iterable object into a Stream and perform some standard operations on it. 2. Converting Iterable to Stream The Iterable interface is designed keeping generality […]

The Difference Between map() and flatMap()

2021 VietMX 0

1. Overview map() and flatMap() APIs stem from functional languages. In Java 8, we can find them in Optional, Stream and in CompletableFuture (although under a slightly different name). Streams represent a sequence of […]

Merging Streams in Java

2021 VietMX 0

1. Overview In this quick article, we explain different ways of merging Java Streams – which is not a very intuitive operation. 2. Using Plain Java The […]

Java 8 Collectors toMap

2021 VietMX 0

1. Overview In this quick tutorial, we’re going to talk about the toMap() method of the Collectors class. We’ll use it to collect Streams into a Map instance. For all the examples […]

New Stream Collectors in Java 9

2021 VietMX 0

1. Overview Collectors were added in Java 8 which helped accumulate input elements into mutable containers such as Map, List, and Set. In this article, we’re going to explore two […]

Hamcrest Collections Cookbook

2021 VietMX 0

1. Introduction This cookbook illustrates how to make use of Hamcrest matchers to work with and test collections. The format of the cookbook is example focused and practical […]