2020
10-10
10-10
使用jdk1.8实现将list根据指定的值去分组的操作
我就废话不多说了,大家还是直接看代码吧~Map<String,List<CommentQuery>>commentList=list.stream().collect(Collectors.groupingBy(CommentQuery::getNewsId));for(Map.Entry<String,List<CommentQuery>>entry:commentList.entrySet()){Stringkey=HOT_LIST_KEY+entry.getKey();if(entry.getValue().isEmpty()){stringRedisTemplate.opsForValue().set(key,"");}else{Gsongson=newGson();Stringjson=g...
继续阅读 >