+ 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;
}
+ 3
Generics are tricky sometimes
+ 2
Where is your code?
+ 1
data is not type Numbers
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.