Online Java Compiler By
JavaTpoint.com
import java.util.ArrayList; import java.util.ListIterator; public class JavaListIteratornextIndexExample2 { public static void main(String[] args) { ArrayList < Float > marks = new ArrayList < Float > (); marks.add(22.4f); marks.add(34.98f); marks.add(12.9f); marks.add(76.4f); System.out.println("The marks are listed as : "+ marks); ListIterator < Float > listIterator = marks.listIterator(); System.out.println("The first Index is given as : " + listIterator.nextIndex()); listIterator.next(); System.out.println("The second Index is given as : " + listIterator.nextIndex()); listIterator.next(); System.out.println("The third index is given as : " + listIterator.nextIndex()); listIterator.next(); System.out.println("The fourth index is given as : " + listIterator.nextIndex()); } }
Output