0

How to generate hashCode () and equals () method

Helle beautiful people of Sololearn, Ahen I tey to generate the hashcode () and equals () method, it comes with the error: "There are non-static fields in the class" What do I have to do to generate the methods? here is the code: class Apples { public static void main (String [] args) { // Some code I didn't put in yet } } kind regards, Tom Post

18th Dec 2016, 11:12 AM
Tom Post
Tom Post - avatar
3 odpowiedzi
+ 1
hi... just follow the steps as stated in the tutorial i.e. "Just right click in your class, go to Source->Generate hashCode() and equals()..." i hope this helps your question, if not, let us know...
20th Mar 2017, 4:21 PM
Taiwo Michael O.
Taiwo Michael O. - avatar
0
You have to instantiate and Apples object With that object you already can make use of equal and hascode methods because this are defined in object superclass Or you can override those methods in your Apples class
18th Dec 2016, 8:25 PM
Dago VF
Dago VF - avatar
0
Well..... Considering this was 3 months ago...
20th Mar 2017, 4:26 PM
Dago VF
Dago VF - avatar