私は Employee という名前の pojo を持っています。今度は、マップに配置したいユーザー定義のコレクションを作成したいと考えています。これを達成する方法を教えてください。
public class Employee {
String name,job;
int salary;
public Employee(String n , String j, int t) {
this.name= n;
this.job=j;
this.salary= t;
}
@Override
public int hashCode() {
return name.hashCode()+job.hashCode()+salary;
}
@Override
public boolean equals(Object obj) {
Employee e = (Employee) obj;
return this.name.equals(e.name) && this.job.equals(e.job)
&& this.salary == e.salary;
}
}