how to 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: java reverse loop
for (int i = aList.size() - 1; i >= 0; i--) {
String s = aList.get(i);
}