You have declared a separate type parameter for your
insertInOrder method, i.e, that method is itself a generic method. So, the type parameter
T in method is different from the one used inside the class, but outside that method.
T#1 is the placeholder created by the compiler for a type parameter. Since the two type parameters are different, that is why there are two different placeholders, and hence they are not compatible. To make it work, just remove the type parameter declaration from your method. Change it to:
Also,the bounds for your type parameter in the class should better be given as:
You should use generic
Comparable, and not raw type. You must be getting an
Unchecked warning there.
In fact, it would be even better to define it like this:
This makes this class to work with a subclass, which implements a
Comparable of some super class.