iterate backwards java code example
Example 1: java iterator backwards
ArrayList<...> a = new ArrayList<...>();
// Add elements to list.
// Generate an iterator. Start just after the last element.
ListIterator li = a.listIterator(a.size());
// Iterate in reverse.
while(li.hasPrevious()) {
System.out.println(li.previous());
}
Example 2: how to iterate through an array backwards java
for (int counter = myArray.length - 1; counter >= 0; counter--) {