import java.util.*;
class Student{
String name;
String age;
public Student(String name,String age){
this.name =name;
this.age=age;
}
public String tostring(){
return "姓名: "+name+"年龄: "+age;
}
public int hashCode(){
return name.hashCode();
}
public boolean equals(Object obj){
if(this==obj) return true;
if(!(obj instanceof Student)) return false;
Student stu=(Student) obj;
boolean b=this.name.equals(stu.name);
return b;
}
}
public class text {
public static void main(String[] args) {
HashSet hs=new HashSet();
Student stu1=new Student("张三","18");
Student stu2=new Student("李四","19");
Student stu3=new Student("王五","17");
hs.add(stu1);
hs.add(stu2);
hs.add(stu3);
System.out.println(hs);
}
}