public class Test001 {
public static void main(String[] args) throws Exception {
Collection c1 = new ArrayList();
c1.add("a");
c1.add("b");
c1.add("c");
c1.add("d");
Collection c2 = new ArrayList();
c2.add("a");
c2.add("b");
c2.add("c");
c2.add("d");
c2.add("e");
c2.add("f");
//取交集,如果调用的集合改变就返回true,如果调用的集合不变就返回false
boolean b = c2.retainAll(c1); //取交集
System.out.println(b);
System.out.println(c2);
}
}


1万+

被折叠的 条评论
为什么被折叠?



