+ 3
method what you want to override in Numbers is Object.equals(Object o) not Object.equals(Numbers o) type parameter AnyType is internally Object search(AnyType data) takes data.equals() method by used parameter type where Numbers has two equals() methods one is inherited from Object and second is non overide it what you can do: class Numbers ... //public boolean equals(Numbers newNum) { public boolean equals(Object object) { if (! (object instanceof Numbers) ) return false; Numbers newNum = (Numbers) object; return this.letters.equals(newNum.letters) && this.digits == newNum.digits; }
16th Mar 2022, 10:22 PM
zemiak
+ 3
Generics are tricky sometimes
16th Mar 2022, 8:10 PM
Oma Falk
Oma Falk - avatar
+ 2
Where is your code?
16th Mar 2022, 4:51 PM
Adil
Adil - avatar
+ 1
data is not type Numbers
16th Mar 2022, 7:11 PM
Oma Falk
Oma Falk - avatar
0
You have no overridden equals method in SinglyLinkedlist Class, in which you are calling. Your expected one is defined it in Numbers class, you cannot access that from other class automatically as you expecting.. . . Override in SinglyLinkedlist Class... Hope it helps.
16th Mar 2022, 6:56 PM
Jayakrishna šŸ‡®šŸ‡³