Online Java Compiler By
JavaTpoint.com
import java.util.*; public class CollectionsFillExample3 { public static void main(String[] args) { List
list = new ArrayList<>(); for (int i = 0; i < 6; i++) list.add("Hi"); System.out.println("Before Fill: "+list); Collections.fill(list, "Hello"); System.out.println("After Fill: "+list); } }
Output