The Difference Between map() and flatMap() 1. Overview map() and flatMap() APIs stem from functional languages. In Java 8, you can find them in Optional, Stream and in CompletableFuture (although under slightly different name). Streams represent a sequence of objects, whereas optionals are classes that represent a value that can… Continue Reading java-difference-map-and-flatmap

Java 8 Stream findFirst() vs. findAny() 1. Introduction The Java 8 Stream API introduced two methods that are often being misunderstood: findAny() and findFirst(). In this quick tutorial, we will be looking at the difference between these two methods and when to use them. Further reading: Filtering a Stream of… Continue Reading java-stream-findfirst-vs-findany

Collect a Java Stream to an Immutable Collection 1. Introduction In this quick article, we’re going to have a look at various ways of collecting Java Streams to immutable Collections – which require a special approach because standard Collectors work only with mutable data structures. 2. Maven Dependency We are… Continue Reading java-stream-immutable-collection

Functional Interfaces in Java 8 1. Introduction This article is a guide to different functional interfaces present in Java 8, their general use cases and usage in the standard JDK library. Further reading: Iterable to Stream in Java The article explains how to convert an Iterable to Stream and why… Continue Reading java-8-functional-interfaces