Four things:
1) As said before, the single argument to the
equals method should have
Object as its type, not
Sym. What you've done is overload the method, not override it.
2) You can merge your check for
null and the
instanceof check into one, because if the argument is
null then
instanceof will return
false for every class.
3) Since
this.symVal is an object (you can call
hashCode() on it), you shouldn't use
== to compare them. Use
this.symVal.equals(other.symVal), or if they can be
null use
Objects.equals(this.symVal, other.symVal).
4) You use
this.symProp in your
hashCode implementation. This means that if two instances have equal values for
symVal but different values for
symProp, the instances are equal but have different hash codes. That's not allowed.
You should either add an equality check for
symProp in
equals, or remove the use of
symProp in
hashCode.
So in short: