I am trying to get from TreeMap but it return null even the key exist. HashCode and eqauls is based on word only. Comparable is based on freqency.
public sta
Since your Word class implements Comparable interface . So TreeMap uses compareTo method for comparing properties of objects.
If you want to get the object with same String "word" then implement compareTo method like
@Override public int compareTo(Word o) { return this.word.compareTo(o.word); }