Whats the Difference Between an Iterator and a ListIterator?
ListIterator has a few additional methods that make scrolling through your LinkedList a little easier. Those additional methods are:
- add()- method that lets you insert while traversing the list
- nextIndex()- returns an int representing the index of the following element
- hasPrevious()- returns a Boolean value (true or false) indicating whether there is an element in the reverse direction
- previous()- returns the element before the current element
- previousIndex() - if there is an element before the current one, returns the index of that element
First, you will need to create a new file in your text editor. Next, import the classes you will need to use for this program by typing the following in your new text file:
import java.util.LinkedList;
import java.util.Iterator;
import java.util.ListIterator;
