Quantcast
Channel: Magnus K Karlsson
Viewing all articles
Browse latest Browse all 526

Java 8 - Streams

$
0
0

What is Stream?

A sequence of elements supporting sequential and parallel aggregate operations.

How to create?

The java.util.Collection interface has two methods:

  • stream()
  • parallelStream() - supports parallel computing.

How to use?

The java.util.stream.Stream interface has several methods, here are the most common used.

filter

map

sorted

forEach

collect

java.util.stream.Collectors

Collectors are used of collecting result from Stream operations, but there are several useful methods in the java.util.stream.Collectors interface. Here some of them.

toList()/toSet()

groupingBy


Viewing all articles
Browse latest Browse all 526

Trending Articles