java有哪种方法的功能与retain all相反?
我有两个清单,比如
List<String> list1 = new ArrayList<String>(Arrays.asList("A", "B", "C"));
List<String> list2 = new ArrayList<String>(Arrays.asList("A"));
List<String> result = list1.(SomeMethod)(list2)
必须返回result = {"B","C"}
这种方法可行吗
# 1 楼答案
有
list1.removeAll(list2)