Did you also override hashCode()?
@Override public int hashCode(){
return studentId;
}
Type: Posts; User: copeg
Did you also override hashCode()?
@Override public int hashCode(){
return studentId;
}
Because you are adding the Student object to your TreeMap, you should over-ride them in that class (similar to the equals you posted). It might be a bit trickier to override them though if you wish...
When placing classes you wrote into classes which implement Map and Set interfaces, you need to make sure that the equals() and hashCode() methods are overridden. Because of the hash based retrieval...