public class ValuePair implements Comparable{
private int iLookUp;
public ValuePair(int iLookUP, String sValue){
this.iLookUp=iLookUp;
}
public void setLookUp(int iLookUp){
this.iLookUp = iLookUp;
}
public int getLookUp(){
return iLookUp;
}
public boolean equals(Object o){
Integer iwLookUp = (Integer) o;
if(iLookUp == iwLookUp.intValue()){
return true;
}
return false;
}
public int compareTo(Object o) {
ValuePair vp = (ValuePair) o;
Integer iwLookUp= new Integer(vp.getLookUp());
if(iwLookUp.intValue() < iLookUp){
return -1;
}
if(iwLookUp.intValue() > iLookUp){
return +1;
}
return 0;
}
}
The valid hashCode method are
public int hashCode(){
return iLookUp;
}
public int hashCode(){
return iLookUp * 100;
}