我想要两个不同类型的循环变量。有什么办法可以使这项工作吗?
@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
啊 它没有在任何地方声明。是班级成员吗?