Java: Iterator and listiterator of the set output
Listiterator is the sub-interface of the iterator, and the greatest feature of iterator is the ability to iterate forward or backward. If you want to output two-way, you can only use the Listiterator interface, this interface has a requirement that only the contents of the list interface can be output. So use the public listiterator<e> extends Iterator<e>:
Add (E): Add data
Boolean hasnext (); Inherit iterator, whether the next element exists,
Next (); Inherit iterator, get the next element content
Previous (); Inherit iterator, get the previous element content
Remove (); Delete the next or previous element
Set (e e); Replace the contents of the next or previous element with the specified element;
If you want two-way output, it is important to first ensure that the output is performed by the front and back.
When using the Listiterator interface, there is also the biggest feature that can increase the modification data.
Java: Iterator and listiterator of the set output