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