Tag: streams

  • Java 8 Stream API

    Java 8 Stream API

    In this article, we’ll learn everything regarding Java Stream API that was introduced in Java 8, through detailed examples. 1. What Is a Java Stream? You can think of a stream as a sequence of elements, that allows you to perform sequential and parallel operations. Furthermore, you cannot add any elements once the stream has…

  • Collectors to Map in Java

    Collectors to Map in Java

    In this article, we’ll go through Collectors to Map method in Java, which is used to convert a stream to a map. 1. Collectors to Map overview The Collectors to Map method is used to transform a Stream of items into a Map. Note that Collectors.toMap() is a terminal operation which means you cannot perform…

  • Java Stream Reduce

    Java Stream Reduce

    In this article, we’ll go through how you can use the Java Stream Reduce method of Stream API. 1. Java Stream Reduce Overview In general, reduce methods are used to combine multiple values into one result; Java stream.reduce() does the same. Also, note that unlike map() and filter(), reduce() is a terminal operation so you…

  • Java Stream Map

    Java Stream Map

    In this article, we’ll go through the Java Stream map() method through detailed examples. 1. Java Stream Map Method Overview The stream.map() method is used to transform an object or primitive into something else. The syntax of this method is the following: The function could have one of the following syntaxes: 1.1 One-Line Lambda The…

  • Java Stream Filter

    Java Stream Filter

    In this article, we’ll go through the Java Stream filter() method through detailed examples. 1. Java Stream Filter Method Overview The stream.filter() method is used to filter an object or a primitive based on the truthness of a boolean. The syntax of this method is the following: The predicate could have one of the following…