public class Test1 {
public static void main(String[] args) {
List<Integer> numbers = new ArrayList<>(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9));
C1 c1 = new C1();
numbers.parallelStream().forEach(c1::method1);//操作元素
}
static class C1 {
public void method1(Integer integer) {
System.out.print(integer + "\t");
}
}
}
TreeMap<String, List<User>> treeMap = userList.stream()
.sorted((o1, o2) -> o1.getAge() - o2.getAge())
.collect(groupingBy(item -> item.getHeight, TreeMap::new, toList()));
java8 stream 用法收集
点赞
收藏