CollectionUtils::removeAll() Commons Collections 3.2.1的Java Commons Collections中的removeAll
我必須要瘋了,監守好像這種方法是做什麼的文檔狀態反:
Removes the elements in remove from collection. That is, this method returns a collection containing all the elements in c that are not in remove.
這一點JUnit測試
@Test
public void testCommonsRemoveAll() throws Exception {
String str1 = "foo";
String str2 = "bar";
String str3 = "qux";
List<String> collection = Arrays.asList(str1, str2, str3);
System.out.println("collection: " + collection);
List<String> remove = Arrays.asList(str1);
System.out.println("remove: " + remove);
Collection result = CollectionUtils.removeAll(collection, remove);
System.out.println("result: " + result);
assertEquals(2, result.size());
}
正在失敗
java.lang.AssertionError: expected:<2> but was:<1>
,並打印
collection: [foo, bar, qux]
remove: [foo]
result: [foo]
從我,我應該想到[bar, qux]
的文檔閱讀。我錯過了什麼?
我更新了我的文章以反映這一點,因爲有人讓我想起了它 - 但Apache Commons Collections 4.0於2013年11月發佈,併爲此問題提供了修復。 – birryree