说如果我有这个琐碎的程序
List<String> input = Arrays.asList("1", "2", "3");
List<String> result = input.stream()
.map(x -> x + " " + x)
.filter(y -> !y.startsWith("1"))
.collect(Collectors.toList());
在幕后它是像 a) 还是 b) 那样工作
一个
map
"1" + " " + "1"
"2" + " " + "2"
"3" + " " + "3"
filter
"1 1" does not begin with "1"? = false
"2 2" does not begin with "1"? = true
"3 3" does not begin with "1"? = true
collect
add "2 2" to list
add "3 3" to list
result = List("2 2", "3 3")
乙
map
"1" + " " + "1"
filter
"1 1" does not begin with "1"? = false
map
"2" + " " + "2"
filter
"2 2" does not begin with "1"? = true
collect
add "2 2" to list
map
"3" + " " + "3"
filter
"3 3" does not begin with "1"? = true
collect
add "3 3" to list
result = List("2 2", "3 3")