public List<Product2Select>getList(String pId){
List<Product2Select> selectChildrenList = childrenList.stream().filter(o -> pId.equals(o.getProductId())).collect(Collectors.toList());
return selectChildrenList;
}
List<Integer> list = new ArrayList() {
{
add(12);
add(20);
add(12);
add(22);
add(22);
add(23);
add(159);
add(12);
}
};
Map<Integer, Long> map = list.stream().collect(Collectors.groupingBy(p -> p,Collectors.counting()));
map.forEach((k, v) -> System.out.println(k + ":" + v));
输出结果
20:1
22:2
23:1
12:3
159:1
List<DictionarySelect> dictionarySelects = dictionary2Mapper.selectDictionary();
Map<String, String> dictMap == dictionarySelects.stream().collect(Collectors.toMap(
DictionarySelect::getValue, DictionarySelect::getId, (oldValue, newValue) -> oldValue, HashMap::new));
List<String> userIdList = taskList.stream().map(Task::getAssignee).collect(Collectors.toList());
List list = new ArrayList();
for(int i=0; i< 5; i++){
list.add(i);
list .stream().forEach(int-> {
System.out.println(int);
});
result.stream().skip(begin).limit(size).collect(Collectors.toList());
List list = new ArrayList();
for(int i=0; i< 5; i++){
list.add(i+ "");
list.stream().filter(comment -> {
return comment + ":" + comment.length;
})