List

boolean retainAll = arrayList.retainAll(arrayList2); //交集 只能做一次
boolean removeAll = arrayList.removeAll(arrayList2); //补集 只能做一次

 

Map

boolean removeAll = map2.keySet().removeAll(map.keySet());//补集 只能做一次 

boolean retainAll = map2.keySet().retainAll(map.keySet());//交集 只能做一次

 

注意:以上操作都会改变 调用removeAll和retainAll的集合,操作前最好先进行数据拷贝

 

MAP

hosts_temp_map.clear();
hosts_temp_map.putAll(HOSTS_MAP);

 

List

arrayList_temp.addAll(arrayList); 

 

相关文章:

  • 2021-08-22
  • 2022-12-23
  • 2021-12-27
  • 2022-12-23
  • 2021-08-14
  • 2021-10-29
  • 2021-09-11
  • 2021-05-24
猜你喜欢
  • 2021-11-12
  • 2021-07-19
  • 2022-12-23
  • 2021-06-25
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案