I am getting this error but i don't know how to fix it
name clash: equals(E) in and equals(java.lang.Object) in java.lang.Object have the same erasure, yet neither overrides the other
I have created a generic sorted set and everything else works apart from the equals method which is in the comparator
Here is the code in question
public Comparator<E> comparator(){
return new Comparator<E>() {
public int compare(E obj1, E obj2) {
Node<E> node1 = (Node) obj1;
Node<E> node2 = (Node) obj2;
return node1.compareTo(node2.getContents());
}
public boolean equals(E obj) {
if (!(obj instanceof OrderedLinkedList)) {
return false;
}
Node<E> newNode = (Node) obj;
return current.getContents().equals(newNode.getContents());
}
};
}
I have included the files to create the sorted set. I have a Node class which creates a node object and the linked list class which implements the SortedSet interface with all of the methods overwritten