저는 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;
}
}
구현을 위해 [항목] 7 및 [여기] (http://java.sun.com/developer/Books/effectivejava/Chapter3.pdf)을 참조하십시오. 같음 및 해시 코드 – luketorjussen