工作中用到了list的取差集,發現還是挺好用的。
所以記錄下。
需求list的方法說明備注
交集listA.retainAll(listB);? listA內容變為listA和listB都存在的對象? ? ? ? listB不變
差集listA.removeAll(listB);? listA中存在的listB的內容去重? ? ? ? ? ?listB不變
并集listA.removeAll(listB);
listA.addAll(listB);
為了去重,listA先取差集,然后追加全部的listBlistB不變
引用鏈接:https://www.cnblogs.com/changfanchangle/p/8966860.html