$ ./guess_the_languageProblem Solving — predict the output
Problem Solving — predict the output · hard · #256

What is the output?

List<Integer> l = new ArrayList<>(List.of(10, 20, 30));
l.remove(1);
System.out.println(l);
  1. [20, 30]
  2. [10, 20]
  3. [10, 30]
  4. [10, 20, 30]
An int argument picks the overload remove(int index), so the element at index 1 (20) goes. remove(Integer.valueOf(1)) would remove by value.
Play Problem Solving ▸