異なるタイプの2つのループ変数が必要です。これを機能させる方法はありますか?
@Override
public T get(int index) throws IndexOutOfBoundsException {
// syntax error on first 'int'
for (Node<T> current = first, int currentIndex; current != null;
current = current.next, currentIndex++) {
if (currentIndex == index) {
return current.datum;
}
}
throw new IndexOutOfBoundsException();
}
first
ですか?どこにも宣言されていません。クラスのメンバーですか?