![](/img/trans.png)
[英]How return a generic array of <T extends Comparable<? super T>> in Java?
[英]Why is my generic implementation not working? (extends Comparable<? super T>>)
我正在使用BinaryNode<T>
實現一個包含信息的Binary搜索樹。 在我的樹類中,我有以下代碼行:
public class BST<T> implements BSTInterface<T extends Comparable<? super T>>
這導致許多錯誤,例如:
BST.java:10: error: > expected
public class BST<T> implements BSTInterface<T extends Comparable<? super T>>
^
BST.java:10: error: <identifier> expected
public class BST<T> implements BSTInterface<T extends Comparable<? super T>>
^
我不確定為什么這行不通,因為那行代碼適用於我的界面。 任何幫助將非常感激! 我可能正在犯一些愚蠢的錯誤。
我想你打算寫
public class BST<T extends Comparable<? super T>> implements BSTInterface<T>
你必須把上界T
在第一次提到T
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.