import java.util.*;
public class ContainerDemo {
public static void main(String args[]){
Collection c1= new ArrayList(25);
c1.add(new String("One"));
c1.add(new String("Two"));
String s = "Three";
c1.add(s);
for(int i=0;i < c1.size();i++)
System.out.println(c1.get(i));
Object[] array = c1.toArray(); //什么意思
String[] str = (String[])c1.toArray(new String[0]); //什么意思
Collection c2 = new ArrayList(2);
c2.add(new String("Four"));
c2.add(new String("Five"));
c1.addAll(c2);
for(int i=0;i<c1.size();i++)
System.out.println(c1.get(i));
Collection c3 = new ArrayList(2);
c3.add(new String("Two "));
c3.add(new String("Five"));
c1.remove(c3);
for(int i=0;i<c1.size();i++)
System.out.println(c1.get(i));
c1.retainAll(c2);
for(int i=0;i<c1.size();i++)
System.out.println(c1.get(i));
}
}
而且最后又错误,显示Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The method get(int) is undefined for the type Collection
The method get(int) is undefined for the type Collection
The method get(int) is undefined for the type Collection
The method get(int) is undefined for the type Collection
at ContainerDemo.main(ContainerDemo.java:10)
。。。。