Java examples for Collection Framework:ArrayList
Replace All Elements Of ArrayList
import java.util.ArrayList; import java.util.Collections; public class Main { public static void main(String[] args) { ArrayList arrayList = new ArrayList(); //w w w . j a va 2 s .co m arrayList.add("A"); arrayList.add("B"); arrayList.add("D"); System.out.println("Before replacement, ArrayList contains : " + arrayList); Collections.fill(arrayList,"REPLACED"); System.out.println("After replacement, ArrayList contains : " + arrayList); } }