public class BasicContainer {
public static void main(String[] args) {
Collection c = new HashSet();
c.add("hello");
c.add(new Name("lu","dongdong"));
c.add(new Integer(100));
System.out.println(c.remove(new Integer(100)));
System.out.println(c.remove(new Name("lu","dongdong")));
}
}
class Name {
private String firstName,lastName;
Name(String firstName,String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
public String toString() {
return firstName + " " + lastName;
}
}
打印出的就是:
true
false