Generics is a powerful tool in Java. But I'm wondering why you're creating a linked list with an Object as the generic.
My suggestion is that you call the generic in the standard Java way and that is with an uppercase
T
public class LinkedList<T>
{
public T doSomething(T c)
{
return c;
}
}
Or at the least, make it a Linked List of Nodes. But I digress.
Let us look at your code. I'm unsure what is returned with the method invocation get_Data_y(), but I am going to assume it's of some Object type. If that's the case you can not use a mathmatical notation such as < > == != etc on it.
Now I know you're asking, but
== worked on the above. Well it sort of did. It worked in the sense that is it comparing the two pointers. But they aren't checking to see if the values are the same. This is why with Objects (
including the class String) you have to use an equals method of some type.
Unfortionatly since you are using the base class of Object you don't have the nifty method compareTo like other classes usually do. All you have use of is equals:
Object (Java 2 Platform SE 5.0)
Anyways, If this isn't the problem, then please post your Node Class so that we can see if we can debug the problem from there.