forEach - , , . forEach , collect . , . map, , , . - :
items.stream()
.filter (s -> s.contains("B"))
.map (s -> { s.setState("ok"); return s; })
.collect(Collectors.toList());
peek, ( - ):
items.stream()
.filter (s -> s.contains("B"))
.peek (s -> s.setState("ok")) // no need to return a value here
.collect(Collectors.toList());