Intermediate stream operations not evaluated on count
问题 It seems I'm having trouble understanding how Java composes stream operations into a stream pipeline. When executing the following code public static void main(String[] args) { StringBuilder sb = new StringBuilder(); var count = Stream.of(new String[]{"1", "2", "3", "4"}) .map(sb::append) .count(); System.out.println(count); System.out.println(sb.toString()); } The console only prints 4 . The StringBuilder object still has the value "" . When I add the filter operation: filter(s -> true)