4
Java:在for循环init中初始化多个变量?
我想要两个不同类型的循环变量。有什么办法可以使这项工作吗? @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(); }