この些細なプログラムがあれば言ってください
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")
B
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")