So all java classes have the hashcode() method by default. We can override these methods in our classes . Hashcode() is a method to return an unique integer which is used for indentifying the bucket where this object will be stored for hashing based collections like HashMap.