I have a Generic class that uses a list it gets from a parameter. When I test to see if two items in the list are equal I get false even if they are equal. I have specified the equals method in the class that the list is made up of, but I can't get it to work. The generic class looks like this:
public static <E> List<E> removeRepeats (List<E> list){
System.out.println(list.get(0).equals(list.get(1));
}
I know the item at index 0 and 1 are equal based on the equality I specified in the classes equal method. But the method returns false every time.
What am i missing?
Thanks,
public static <E> List<E> removeRepeats (List<E> list){
System.out.println(list.get(0).equals(list.get(1));
}
I know the item at index 0 and 1 are equal based on the equality I specified in the classes equal method. But the method returns false every time.
What am i missing?
Thanks,