标签:out slist concat employee for map sys ns2 flat
1.
List<Children> reduce = list.stream()
.map(x -> x.getChildren())
.reduce(new ArrayList<>(), (all, item) -> {
all.addAll(item);
return all;
});
System.out.println(reduce);
2.
List<Children> collect = list.stream()
.map(Employee::getChildren)
.flatMap(Collection::stream)
.distinct().collect(Collectors.toList());
----------------------------
List<Children> childrens1 = new ArrayList<>();
for (long i =0;i<10;i++){
childrens1.add(new Children(i,"x".concat(i+"")));
}
List<Children> childrens2 = new ArrayList<>();
for (long i =100;i<110;i++){
childrens2.add(new Children(i,"x".concat(i+"")));
}
Employee mazi = new Employee("麻子", 90, 989.2);
mazi.setChildren(childrens1);
Employee lisi = new Employee("李四", 10, 1000.1);
lisi.setChildren(childrens2);
List<Employee> list = Arrays.asList(mazi,lisi);
标签:out slist concat employee for map sys ns2 flat
原文地址:https://www.cnblogs.com/wanjn/p/12142701.html