0
我得到了與泛型類問題,我會與我的示例類來解釋它:錯誤與泛型類擴展等通用類
二叉樹
public class BinaryTree<T extends Comparable<T>> {
收錄
public abstract class Indexed<T extends Comparable<T>> implements Comparable<Indexed<T>> {
IndexedBinaryTree
public class IndexedBinaryTree<T extends Indexed<? extends Comparable<Indexed<?>>>> extends BinaryTree<T> {
示例類擴展索引
public class Vokabel extends Indexed<String> {
IndexedBinaryTree不起作用。我正在試圖做的是具有包含索引對象,並且可以像下面這樣創建的二叉樹:
IndexedBinaryTree<Vokabel> ibt = new IndexedBinaryTree<>();
的錯誤的NetBeans是給我:
類型參數?擴展可比>不在範圍 類型變量T 的界限,其中T是一個類型變量: 牛逼延伸可比在索引類中聲明
> expected type argument T#1 is not within bounds of type-variable T#2 where T#1, T#2 are type-variables: T#1 extends Indexed<? extends Comparable<Indexed<?>>> declared in class IndexedBinaryTree T#2 extends Comparable<T#2> declared in class BinaryTree
怎麼辦你的意思是「不工作」?詳細信息,請。 – 2014-09-19 13:17:06
定義不起作用。發佈錯誤以及預期的行爲是什麼。 – 2014-09-19 13:17:09
編輯的主帖(http://i.imgur.com/SRx0iDv.png - 錯誤的屏幕截圖) – Joba 2014-09-19 13:24:51