Collection
RetainAll :保留两个Collection的交集。注意,如果该Collection是由Arrays.asList转换而来,那么这个方法会失败。因为转换来的List接口不支持这个方法
Samples:
public static void collectionTest()
{
Collection c1 = new ArrayList();
Collection c2 = new ArrayList();
c1.add("aaa");
c1.add("bbb");
c1.add("ccc");
c2.add("ddd");
c2.add("ccc");
c2.add("eee");
boolean isRetainSucceed = false;
isRetainSucceed = c2.retainAll(c1);
System.out.println("isRetainSucceed = " + isRetainSucceed);
System.out.println(...[ 查看全文 ]