找出在另一个数组列表中不存在的数组列表的元素 [英] find out the elements of an arraylist which is not present in another arraylist
本文介绍了找出在另一个数组列表中不存在的数组列表的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须找到一个最好的方法来找出没有出现在第二个数组列表的元素。
假设
I have to find a best way to find out that elements which is not presented in the second arraylist. suppose
Arraylist a,b,
Arraylist a={1,2,3,4,5};
Arraylist b={2,3,4};
所以基本上我想要的是找出 a
So basically what I want is to find out that elements of a which is not present in arraylist b.
那么最好的解决方案是什么呢?
So what is the best solutions to do that?
推荐答案
List<Integer> c = new ArrayList<>(a);
c.removeAll(b);
也考虑使用Sets而不是列表。
Also consider to use Sets instead of Lists.
这篇关于找出在另一个数组列表中不存在的数组列表的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文