In this example we will show the method to change an item in an ArrayList in Java.
Source Code
package com.beginner.examples;
import java.util.ArrayList;
public class ChangeArrayList {
public static void main(String[] args) {
ArrayList strs = new ArrayList();
strs.add("a");
strs.set(0, "b");
System.out.println(strs);
}
}
Output:
[b]
References
Imported packages in Java documentation: