Online Java Compiler By
JavaTpoint.com
import java.util.ArrayList; import java.util.ListIterator; public class JavaListIteratorsetExample2 { public static void main(String[] args) { ArrayList
obj = new ArrayList<>(); obj.add(44.7f); obj.add(67f); obj.add(78f); obj.add(98.9f); System.out.println("The list of marks of the students is given as: "+obj); System.out.println("Before using the set() method : "); ListIterator
iterator = obj.listIterator(); while (iterator.hasNext()) { System.out.println(iterator.next()); } iterator.set(12.4f); System.out.println("After using the set() method : "); for (Float item : obj) { System.out.println(item); } } }
Output