~/ learn/ java-from-zero/ cards/ List: ArrayList vs LinkedList
1 of 4

Type common List operations on an ArrayList

Type common List operations on an ArrayList

Answer

List<String> list = new ArrayList<>(List.of("a", "b", "c")); list.add("d"); String second = list.get(1); // "b" list.remove("a"); System.out.println(list.size());

ArrayList wraps a resizable array. get(i) is O(1). We wrap List.of() in new ArrayList<>() to get a mutable copy.

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/e17f6566-5fd0-4dc0-a6b0-8b23459362fb/flashcard utf-8 LF