searchTreeクラス内に再帰メソッドを記述しようとしていますが、何らかの理由で、メソッドは、メソッド自体を調べるのではなく、インターフェイスのクラスの外側を調べてメソッドの定義を探しています。コードのスニペットは次のとおりです。
メインクラス:
public class BinarySearchTree<T extends Comparable<T>> implements BinarySearchTreeInterface1<T>, BinarySearchTreeInterface2<T>{`
Main内の再帰メソッド:
public int getHeight(){
if (isEmpty()){
return 0;
}else{
int height = 1 + Math.max(this.getLeftSubTree().getHeight(),
this.getRightSubTree().getHeight());
return height;
}
}`
ご覧のとおり、2つのインターフェイスクラスがあります。エラーはgetHeight()に下線を引き、次のように述べています。
cannot find symbol
symbol: method getHeight()
location: interface BinarySearchTreeInterface1<T>
where T is a type-variable:
T extends Comparable<T> declared in class BinarySearchTree
Interface2ファイルに示されている5つの再帰メソッドがあり、それらすべてで同じエラーが発生しています。助けてくれてありがとう。
更新:インターフェイスクラスは大学のクラスのものであるため、投稿することを躊躇しています。インストラクターを怒らせたくありません。皮肉なことに、非再帰的な方法は問題なく機能します。Interface2ファイルが示す内容のごく一部を次に示します。
public interface BinarySearchTreeInterface2<T>{
public int getNumberOfNodes();
public int getHeight();