Online Java Compiler By
JavaTpoint.com
import java.util.ArrayList; import java.util.ListIterator; public class JavaListIteratorremoveExample3 { public static void main(String[] args) { ArrayList < Integer > marks = new ArrayList < Integer > (); marks.add(25); marks.add(30); marks.add(35); marks.add(40); marks.add(45); System.out.println("The list for the ages is given as :"+marks); ListIterator < Integer > listIterator = marks.listIterator(); System.out.println("Before remove() method is called. : " + marks); listIterator.next(); listIterator.next(); listIterator.remove(); listIterator.next(); System.out.println("After remove() method is called.: " + marks); } }
Output