ArrayList
ArrayList is a resizable list. Use add, get, set, remove, size and contains.
Example
import java.util.ArrayList;
public class Main {
public static void main(String[] args) {
ArrayList<String> l = new ArrayList<>();
l.add("a"); l.add("b"); l.set(0, "z");
l.remove("b");
System.out.println(l + " " + l.size() + " " + l.contains("z"));
}
}Result
[z] 1 true
Exercise
Add an item.
l.("x")
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.