I was trying the following code,
public void test() {
List<Integer> list = new ArrayList<>();
list.add(100);
list.add(89);
System.out.println(list);
update1(list);
System.out.println(list);
update2(list);
System.out.println(list);
}
public void update1(List<Integer> list) {
list.remove(0);
}
public void update2(List<Integer> list) {
list = null;
}
I am getting the following output,
[100,89]
[89]
[89]
My question is, why I am not able to assign the list as null inside a called function?