How to check whether the elements of an ArrayList are all contained in another ArrayList

倖福魔咒の 提交于 2019-11-28 02:28:54

问题


How can I easily check to see whether all the elements in one ArrayList are all elements of another ArrayList?


回答1:


Use Collection.containsAll():

boolean isSubset = listA.containsAll(listB);



回答2:


There is a containsAll method in all collections.



来源:https://stackoverflow.com/questions/808394/how-to-check-whether-the-elements-of-an-arraylist-are-all-contained-in-another-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!