Created
August 23, 2013 13:11
-
-
Save Alcar32/6319201 to your computer and use it in GitHub Desktop.
Iterate reverse throu a list with list listiterator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Substitute appropriate type. | |
| 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()); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment