CollectionUtils::removeAll() Commons Collections 3.2.1Java Commons Koleksiyonları removeAll
ne dokümanlar devletin tersini yapıyor bu yöntem gibi görünüyor çünkü ben deliriyorum olmalı:
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.
Bu küçük JUnit test
@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());
}
Benjava.lang.AssertionError: expected:<2> but was:<1>
[bar, qux]
beklemeliyim dokümanlar benim okuma itibaren
ve baskılar
collection: [foo, bar, qux]
remove: [foo]
result: [foo]
. Neyi özledim?
Birisi bana bunu hatırlattığından beri bunu yansıtmak için gönderiyi güncelledim - ancak Apache Commons Collections 4.0, bu sorun için bir düzeltme ile Kasım 2013'te yayımlandı. – birryree