Answers for "java iterator backwards"

0

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());
}
Posted by: Guest on October-15-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language