eclipse - Why do hashCode & equal need non-static fields to be generated? -


i curious error while testing out eclipses' functionality:

enter image description here

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

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -