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 }