容器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 @   glt66  阅读(148)  评论(0)    收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示