Java examples for Collection Framework:ArrayList
Replace an element at specified index of ArrayList
import java.util.ArrayList; public class Main { public static void main(String[] args) { ArrayList arrayList = new ArrayList(); /*w w w. j a v a 2 s .co m*/ arrayList.add("1"); arrayList.add("2"); arrayList.add("3"); arrayList.set(1,"REPLACED ELEMENT"); System.out.println("ArrayList contains..."); for(int index=0; index < arrayList.size(); index++) System.out.println(arrayList.get(index)); } }