以下のように定義されたノード クラスがありますが、Eclipse で引き続きエラーが発生します。
void は変数 connectNode の無効な型です
理由を説明してください。
class Node{
char label;
boolean visited = false;
public Node (char l){
this.label=l;
}
public String toString() {
return Character.toString(label);
}
}
以下のように ArrayList を定義しました。
ArrayList<Node> nodes = new ArrayList<Node>();
次のメソッドを使用して、開始インデックスと終了インデックスの値を出力しようとしています
public void connectNode(Node start,Node end){
int startIndex=nodes.indexOf(start);
int endIndex=nodes.indexOf(end);
System.out.println(startIndex);
System.out.println(endIndex);
}