List<Integer> list = new ArrayList<>();
list.add(1);
list.add(0);
list.add(0);
list.removeAll(list.subList(0, 1));
System.out.println(list);
If I run this code, it gives [0].
List<Integer> list = new ArrayList<>();
list.add(1);
list.add(0);
list.add(1);
list.removeAll(list.subList(0, 1));
System.out.println(list);
This gives [0, 1]...
Why are they different? More importantly, why it gives [0] in the first case?