List
List<Integer> list = new ArrayList<>();
list.forEach(value -> {
System.out.println(" Value = " + value);
});
List去重
List<Integer> list = allItemList.stream().distinct().collect(Collectors.toList());
List过滤
itemList.stream().filter(item -> "a".equals(item.getName())).collect(Collectors.toList());
按某个属性值查找对象集合中符合条件的对象
XxxBO xxxBO = itemList.stream().filter(item -> item.getId().equals(xxx)).findFirst().orElse(new XxxBO());
HashMap
Map<Integer, String> map = new HashMap<>();
map.forEach((key, value) -> {
System.out.println("Key = " + key + " " + " Value = " + value);
});
hashmap根据value逆序排序
HashMap<String, Integer> mergeAmountDesc = mergeAmount.entrySet()
.stream()
.sorted(Collections
.reverseOrder(Map.Entry.comparingByValue()))
.collect(Collectors
.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));