import java.util.*;
class Collectiontoarry
{
public static void main(String[] args)
{
Collection<String> con = new ArrayList<String>();
con.add("22");
con.add("23");
con.add("24");
con.add("25");
System.out.println("长度:"+con.size());
Iterator<String> it = con.iterator();
while(it.hasNext())
{
System.out.println(it.next());
}
System.out.println("----------------------------");
con.remove("23");
Object[] obj = con.toArray();
for(int i=0;i<obj.length;i++)
{
String s = (String)obj[i];
System.out.println(s+"字符长度"+s.length());
}
}
} |
|