Online Java Compiler By
JavaTpoint.com
import java.util.*; public class CollectionsFillExample1 { public static void main(String[] args) { //Create a list object List
arrlist = new ArrayList
(); //Add elements in the list arrlist.add("AAA"); arrlist.add("BBB"); arrlist.add("CCC"); System.out.println("List elements before Replacements: "+arrlist); //Fill the list with 'JavaTpoint' Collections.fill(arrlist,"JavaTpoint"); System.out.println("List elements after Replacements: "+arrlist); } }
Output