public class Employee {
private int id;
private String name;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
return "Employee [id=" + id + ", name=" + name + "]";
}
public Employee(int id, String name) {
super();
this.id = id;
this.name = name;
}
}
Set<Employee> set = new HashSet<Employee>();
Employee e2 = new Employee(3,"Mohan");
Employee e3 = new Employee(4,"Shayam");
Employee e4 = new Employee(5,"rahul");
Employee e = new Employee(1,"rahul");
Employee e1 = new Employee(2,"ram");
当hashset包含一些用户定义的对象时,如何对此HashSet进行排序?