June 2025
Intermediate to advanced
1129 pages
53h
English
Not all terminal operations result in a new modified stream but instead may simply terminate the current stream. The situation is different for intermediary operations, which modify the stream, for example, by removing elements, mapping them to other values and types, or sorting elements. Each intermediary method returns a new stream object, as seen in Table 18.4 .
|
Full Notation |
Cascaded Notation |
|---|---|
Stream<Object> a = Stream.of(" ",'3',null,"2",1,"");Stream<Object> b = a.filter(Objects::nonNull);Stream<String> c = b.map(Objects::toString );Stream<String> d = c.map(String::trim);Stream<String> e = d.filter(s -> !s.isEmpty());Stream<Integer> f = e.map(Integer::parseInt);Stream<Integer> g = f.sorted(); ... |
Read now
Unlock full access