Consider the code:
public abstract class Item implements Comparable
{
protected T item;
public int compareTo(T o)
{
re
For objects of type X
to be comparable with each other, class X
has to implement exactly Comparable
.
This is not what your code is doing, you've got a class Item
and you are implementing Comparable
instead of Comparable
. This means that Item
can be compared with T
, but not with Item
, which is required.
Change your Item
class to:
public abstract class Item implements Comparable- >
{
protected T item;
@Override
public int compareTo(Item
o)
{
return 0; // this doesn't matter for the time being
}
}