In this tutorial, we are going to learn how to Iterate an ArrayList using ‘ListIterator’ in Java with example(s).The listIterator() method is part of java.util class (specifically from java.util.ArrayList). It allows to traverse the list in either direction forward or backward, modify the list during iteration, and obtain the iterator’s current position in the list.  

Look at ListIterator Javadoc description below:

ListIterator Javadoc

Check out: Unique ways to Filter an ArrayList in Java

ListIterator in Java with Examples...!!! Click To Tweet

Example 1. Iterate through the List in the ‘Forward / Backward Direction’

Output:
 

Example 2. Iterate through the List and start from a ‘Specified Position’ using Index

Output:
 

In Java Programming, Iterator and ListIterator both are very commonly used ways to iterate through an ArrayList. ListIterator has no many methods other than hasNext(), hasPrevious() and Index like add, nextIndex, previousIndex, remove and set. All these methods are commonly used as well based on the coding requirement. At Techndeck, will try to create more tutorials in the future to explain them as well. But for now, go ahead and give them a try. I hope above example(s) could help you to get a better understanding on ListIterator in Java.

ListIterator in Java with Examples...!!! Click To Tweet

Do you like this Post? – then check my other helpful posts:

Other Useful References: