記錄一下自己用的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();