How to implementation hashcode method for my class with a string method
<p>I have an abstract class and I wanted to force all the implementations of the class to implement there own equals and hashCode method. The class has just one method which returns a String.</p>

<p>The abstract class is defined like this</p>

<pre><code>public abstract class Type
{
   public abstract String getType();
   public abstract boolean equals(Object other);
   public abstract int hashCode();
}
</code></pre>

<p>I have implemented the equals method. Now I am implementing the hashCode method for this class. I have a couple of questions:</p>

<p>1) Is this the right approach to override the == behavior in all implementations of the class.</p>

<p>2) What would be the best way to implement the hashCode method for this class which only has one function that returns a string?</p>

<p>Is this is a duplicate, please point me to the right answer.</p>