When overriding the equals() and hashCode() methods of a class, would the following approach work?
All my logic to see if the objects are equal is done in my equals() method. The class has a static variable (we'll call it hashCodeReturn) that is set to 1.
When ever the equals method reaches logic that would return false, it adds 1 to hashCodeReturn
The hashCode() then simply returns the hashCodeReturn value
Is there any reason this would not work?
Many thanks.