public class TowerOfHanoi<E> {
private class Disk<T extends Comparable<E>> {
}
private class Peg<S extends Disk<T extends Comparable<E>>> extends Stack<Disk<T extends Comparable<E>>> {
}
}
With the above code, I'm getting the following compilation error.
Syntax error on token "extends", , expected
However, if I change the definition of Peg as follows, it works:
private class Peg<T extends Disk<? extends Comparable<E>>> extends Stack<Disk<? extends Comparable<E>>> {
}
I don't want to use a wildcard. Is there a way to change that to a named parameter?
You can't use generics like that. Simply pass the type (not the bound) to the extended type.
This compiles: