Chcę mieć dwie zmienne pętli różnych typów. Czy jest jakiś sposób, aby to zadziałało?
@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? Nigdzie nie jest deklarowane. Czy to jest członek klasy?