//比较两个list
//取出存在storeList中,但不存在storeSubList中的数据,差异数据放入differentList
private void listCompare(List<StoreOut> storeList, List<StoreOut> storeSubList) {
Map<StoreOut,Integer> map = new HashMap<>(storeSubList.size());
List<StoreOut> differentList = new ArrayList<>();
for(StoreOut storeOut: storeSubList){
map.put(storeOut,1);
}
for(StoreOut storeOut1 : storeList){
if(map.get(storeOut1)==null){
differentList.add(storeOut1);
}
}
}
java中比较两个list中去出不同的放在一个list中
最新推荐文章于 2023-12-14 10:23:22 发布
本文介绍了一种在Java中比较两个列表(List)的方法,旨在找出存在于主要列表中但不在子列表中的元素。通过使用HashMap数据结构,文章详细阐述了如何高效地实现这一功能,这对于数据对比和差异分析具有重要意义。

325

被折叠的 条评论
为什么被折叠?



