public class HashTest{
private int i;
public getInt(){
return i;
}
public void setI(int i){
this.i=i;
}
public boolean equals(Object object){
if(object==null)
return false;
if(object==this)
retrun true;
if(!(object instanceof HashTest))
return false;
HashTest other=(HashTest) object;
if(other.getI()==this.getI())
return true;
return false;
}
public int hasCode(){
return i%10;
}
}
能放进hashmap的一个自定义类
最新推荐文章于 2022-04-13 15:10:01 发布