Please override hashCode() as well since you overrode equals(), especially if it is going to be used as keys for a hash-based data structures.