java 如何获取得到两个list中不同的数据
1个回答
展开全部
// list不支持removeAll,removeAll修改集合本身
List list1 = Arrays.asList("a","b","c");
List list2 = Arrays.asList("b","c","d");
Set set1 = new HashSet(list1);
Set set2 = new HashSet(list2);
set1 .removeAll(set2 );//set1 : a
Set set3 = new HashSet(list1);
set2 .removeAll(set3 );//set2 : d
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询