一般重写equals, 需要重写hashcode。for hash Collection usage
[quote]
public boolean equals(Object o){
if(o==this)
return true;
if(!(o instanceof CatchFinally))
return false;
CatchFinally cf = (CatchFinally)o;
return cf.keyfield == this.keyfield&&this.keyfield2.equals(cf.keyfield2);
}
public int hashCode(){
int result =17;
result = 37*result + keyfield;
result = 37*result + keyfield2;
return result;
}
[/quote]
[quote]
public boolean equals(Object o){
if(o==this)
return true;
if(!(o instanceof CatchFinally))
return false;
CatchFinally cf = (CatchFinally)o;
return cf.keyfield == this.keyfield&&this.keyfield2.equals(cf.keyfield2);
}
public int hashCode(){
int result =17;
result = 37*result + keyfield;
result = 37*result + keyfield2;
return result;
}
[/quote]