我是靠谱客的博主 直率世界,这篇文章主要介绍JAVA8循环两个List表,现在分享给大家,希望可以做个参考。

//循环两个列表通过ENDTIME与TIME相等将profitOfferRespList列表的Value放入profitRespList的CountPrice。以profitRespList为主表最后返回的事profitRespList
for (AggregatorDeviceDateProfitResp pro : profitRespList){
profitOfferRespList.stream().filter(s->s.getTime().equals(pro.getEndTime())).forEach(s->pro.setCountPrice(s.getValue()));
}
//如果对性能要求高可以将 副List转换成Map的形式这样可以减少副List的循环
Map<String, List> map = profitOfferRespList.stream().collect(groupingBy(DataResp::getTime));
for (AggregatorDeviceDateProfitResp pro : profitRespList){
List dataResps = map.get(pro.getEndTime());
if(CollectionUtils.isNotEmpty(dataResps)){
pro.setCountPrice(dataResps.get(0).getValue());
}
}

最后

以上就是直率世界最近收集整理的关于JAVA8循环两个List表的全部内容,更多相关JAVA8循环两个List表内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(50)

评论列表共有 0 条评论

立即
投稿
返回
顶部