Online Java Compiler By
JavaTpoint.com
import java.util.ArrayList; import java.util.ListIterator; public class JavaListIteratorsetExample3 { public static void main(String[] args) { ArrayList
sub = new ArrayList<>(); sub.add(23l); sub.add(56l); sub.add(34l); sub.add(98l); System.out.println("The list of numbers of the students is given as: "+sub); System.out.println("Before using the set() method : "); ListIterator
iterator = sub.listIterator(); while (iterator.hasNext()) { System.out.println(iterator.next()); } iterator.set(12l); System.out.println("After using the set() method : "); for (Long item : sub) { System.out.println(item); } } }
Output