Assignment two arrays in a method receiving an array but contents of not changed,why
public class Sol {
public static void main(String[] args) {
int[] list = {1, 2, 3, 4, 5};
reverse(list);
for (int i = 0; i < list.length; i++)
System.out.print(list[i] + " ");// here it prints after reversing 1 2 3 4 5 why?
}
public static void reverse(int[] list) {
int[] array = new int[list.length];
for (int i = 0; i < list.length; i++)
array[i] = list[list.length - 1 - i];
list = array; here is the problem // is it call by value //here assignment why does not change the contents after exit from the method
i do not ask about call by reference and i do not need answers for the code
i need to understand this statement (list = array; why is it call by value when exiting from the method reversing disappeared)
}
}