CollectionUtils::removeAll() Commons Collections 3.2.1जावा कॉमन्स संग्रह 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]
की उम्मीद करनी चाहिए की मेरी पढ़ने से
। मुझे क्या याद आया?
मैंने अपनी पोस्ट को इस पर प्रतिबिंबित करने के लिए अपडेट किया क्योंकि किसी ने मुझे इसकी याद दिला दी - लेकिन इस मुद्दे के लिए एक उपाय के साथ अपाचे कॉमन्स कलेक्शन 4.0 नवंबर 2013 में जारी किया गया था। – birryree