记录一下自己用的JAVA8的一些操作
1.list里面元素类型转换
String 类型的list
list.stream().map(e -> Integer.valueOf(e)).collect(Collectors.toList());
2.根据list分组转成map
Map<String, List<Object>> crossingSaturationMap =
all.stream().collect(Collectors.groupingBy(e -> e.getName()));
3.按照对象里面某个字段排序(逆序)
v.stream().sorted(Comparator.comparing(Object::getName).reversed()).collect(Collectors.toList())
4.java8 list 求和
Double aDouble =
ds.stream().filter(v -> v.getValue() != null).map(DoubleTest::getValue).reduce(Double::sum).get();