本帖最后由 yaowenjiang 于 2011-12-7 18:05 编辑
import java.util.*;
public class PersonOne{
public static void main(String [] args){
Collection c=new ArrayList();
c.add("Hello");
c.add(new Name("J1","K2"));
c.add(new Integer(100));
System.out.println(c);
}
}
class Name{
private String firstName;
private String lastName;
Name(String f,String l){
firstName=f;
lastName=l;
}
public String getFirstName(){
return firstName;
}
public String getLastName(){
return lastName;
}
public String toString(){
return firstName+" "+lastName;
}
} |
|