ArrayList<Integer> list = new ArrayList<>();
list.add(1);
list.add(2);
list.add(3);
list.add(1, 99);
list.remove(2);
System.out.println(list);What is printed?
- Acheck_circle
[1, 99, 3]
- B
[99, 1, 3]
- C
[1, 2, 3]
- D
[1, 99, 2]
Explanation
After add(1, 99) the list is [1, 99, 2, 3]. Then remove(2) removes the element at index 2 (which is 2), giving [1, 99, 3].