java - What is the meaning of the listIterator API description? -
this API:
/// List of elements in this list gives the itator ( Public List Intermediate & lt; E & gt; appropriate sequence list & lt; Integer & gt; List = New Arrestist & lt; Integer & gt; (); List.add (1); List.add (2); List.add (3); // What is the sequence given by i1 and i2? ListIterator & LT; Integer & gt; I1 = list.listIterator (); ListIterator & LT; Integer & gt; I2 = list.listIterator (); I1.next (); Int results = i1.next (); // is the result 2? Or random? In the sequence of index, it is repeated in the listitator object return, and i1,
import java.util.ArrayList; Import java.util.list; Import java.util.ListIterator; Public Sector Main {Public Stable Zero Main (String [] Args) {List & lt; Integer & gt; List = New Arrestist & lt; Integer & gt; (); List.add (1); List.add (2); List.add (3); // What is the sequence given by i1 and i2? ListIterator & LT; Integer & gt; I1 = list.listIterator (); ListIterator & LT; Integer & gt; I2 = list.listIterator (); While (i1.hasNext ()) {System.out.println (i1.next ()); } While (i2.hasNext ()) {System.out.println (i2.next ()); Output is: 1 2 3 1 2 3
Comments
Post a Comment