eclipse - Why do hashCode & equal need non-static fields to be generated? -
i curious error while testing out eclipses' functionality:
i tried use command "generate hashcode & equals", because class has static methods rejected it. how work(i.e. hashcode/equals needing non-static methods ? )?
thank you
hashcode
, equals
methods belonging concrete object , need members belonging object compute meaningful value.
eg. if want compare 2 instances of same class, comparing "computed values" through equals
and/or hashcode
methods.
static methods , members belong class , not concrete instance uniquely.
Comments
Post a Comment