Home Fabio Cortesi Stefan Jäger

Welcome to the Joint-Venture Blog from Fabio Cortesi and Stefan Jäger.

 

 
 

 

Today, I had the problem to iterate backwards in a ArrayList. Didn’t know, there is a ListIterator:

List<string> theList = new ArrayList<string>();
theList.add("a");
theList.add("b");
theList.add("c");
ListIterator<string> liter = theList.listIterator(theList.size());
while (liter.hasPrevious()) {
  System.out.println(liter.previous());
}

 

 

 

 

 
Leave a comment