I'm having a weird problem I don't understand how to solve. Here is the declaration of the class in which the error is appearing:
public class DList<V extends Comparable<V>> { ...
Down below I have a method which has the following signature:
public DList<DList<V>> split(int steps) { ...
which gives me the specific error
Bound mismatch: The type DList<V> is not a valid substitute for the bounded parameter <V extends Comparable<V>> of the type DList<V>
So far the problem is the following class accepts type V which has an upper limit of Comparable, but the recursive type DList isn't accepted. How can I solve this sort of 'recursion' of types and get rid of the error?
Have DList
implement Comparable
:
public class DList<V extends Comparable<V>> implements Comparable<DList<V>> {
@Override public int compareTo(DList<V> other) {
return 0;
}
}
then make sure that the substitute for V
is well bounded:
public class Other {
public static <X extends Comparable<X>> DList<DList<X>> split(int steps) {
return null;
}
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments