peekはimediate processの途中で値を出力したりするときに使う
値を変更はしない
stream lineはeach elementについてfilter,peek,map,forEachされるイメージ
public class Outer {
public static void main(String[] args) {
List<String> l = List.of(
"sato-a",
"sato-b",
"sato-c1",
"sato-d1"
);
Stream<String> s = l.stream();
s.filter(x -> x.length() == 6).peek(System.out::println).map(x -> x.toUpperCase()).forEach(System.out::println);
}
}
sato-a
SATO-A
sato-b
SATO-B