Streams in general perform input and output of data. Java 8 added a package called java.util.stream to stream the output and the input of functions. That means that functions can be piped together.
A stream can be created by calling the method stream():
Stream<String> s = myArrayList.stream();
It can also be created by using Stream.of() on a series of objects:
Streams = Stream.of("a","b");
Here's a code example that uses streams:
Stream.of(5,4,8,1) .map(n -> 2 * n) .sorted() .filter(s -> s < 10) .forEach(System.out::println);
Operations are either intermediate or terminal, where the last operation is always terminal.
Copyright © 2013 Welcome to the website of Davis Fiore. All Rights Reserved.