collect 的第三个参数是干什么用的,即使是一个空代码块运行结果还是不变
public class Stream2Coll {
public static void main(String[] args) {
List<String> stupidList = new ArrayList<>();
stupidList.add(" hello ");
stupidList.add("world ");
LinkedList<Object> collect = stupidList.stream().map(String::trim).collect(
LinkedList::new,
LinkedList::add,
(listOne, listTwo) ->{
//有没有这句结果一样
listOne.addAll(listTwo);
});
collect.forEach(System.out::println);
}
}
1
napsterwu 2017-05-27 00:17:46 +08:00
看文档啊 最后一个是 combiner
|