容器API_Collection_1

 1 import java.util.*;
 2 
 3 class Name
 4 {
 5     public String name;
 6     public String sex;
 7     public Name(String name,String sex)
 8     {
 9         this.name=name;
10         this.sex=sex;
11     }
   public String toString()
    {
        return name+"  "+sex;
    }
12 } 13 14 public class testarrlist { 15 /** 16 * @param args 17 */ 18 public static void main(String[] args) { 19 // TODO Auto-generated method stub 20 Collection c=new ArrayList(); 21 c.add("hello"); 22 c.add(new Name("f1","l1")); 23 c.add(new Integer(100)); 24 System.out.println(c.size()); 25 System.out.println(c); 26 27 } 28 29 }

posted @ 2013-04-05 14:56  glt66  阅读(148)  评论(0编辑  收藏  举报