Quiero tener dos variables de ciclo de diferentes tipos. ¿Hay alguna manera de hacer funcionar esto?
@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? No se declara en ninguna parte. ¿Es un miembro de la clase?