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...
继续阅读 >
一.删除数组中所有指定值先看一种危险的方式:<!DOCTYPEhtml><html><head><metacharset="utf-8"><title></title></head><body><scripttype="text/javascript">window.onload=function(){vararr=[1,1,2,2,3,3,4,4,5,5];console.log(`原始数组:${arr}`);arr.forEach((item,i)=>{if(item==3){arr.splice(i,1);//从下标i开始,...