java8新特性之List处理

分组:

1
Map<String, List<T>> yearData = allData.stream().collect(Collectors.groupingBy(T::getYear));

过滤筛选(单条件):

1
List<T> filterList = appleList.stream().filter(a -> a.getName().equals("YC")).collect(Collectors.toList());

过滤筛选(多条件):

1
2
3
List<T> filterList = dayVoList.
stream().filter(a -> a.getYEAR().equals(item)).collect(Collectors.toList())
.stream().filter(a -> a.getPrice() != "0" && a.getPrice() != "0.0").collect(Collectors.toList());

文章目录