import java.util.ArrayList;
public static ArrayList<Integer> build() {
ArrayList<Integer> a = new ArrayList<>();
a.add(1); a.add(2); a.add(3);
a.add(1, 5);
a.remove(2);
a.set(0, 9);
return a;
}
// Call: System.out.println(build());What is printed?
- Acheck_circle
[9, 5, 3]
- B
[9, 5, 2, 3]
- C
[1, 5, 3]
- D
[9, 1, 5, 3]
Explanation
Start [1,2,3]. add(1,5) -> [1,5,2,3]. remove(2) removes index 2 -> [1,5,3]. set(0,9) -> [9,5,3].