import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import org.junit.Test;
public class TestCollection {
@Test
public void testAddAllAndContainsAll(){
Collection<String> c1 = new ArrayList<String>();
c1.add("java");
c1.add("cpp");
c1.add("php");
c1.add("c#");
System.out.println(c1);
Collection<String> c2 = new HashSet<String>();
c2.addAll(c1);
System.out.println(c2);
Collection<String> c3 = new ArrayList<String>();
c3.add("java");
c3.add("cpp");
System.out.println(c1.containsAll(c3));
}
}
时间: 2024-12-07 07:22:44