Why has the array num not changed and the member method shows that num has been changed
public class Code_189 {
public void rotate(int[] nums, int k) {
int[] temp;
for (int i = 0; i < k; i++) {
temp = new int[nums.length];
System.arraycopy(nums,0, temp, 1, nums.length-1);
temp[0] = nums[nums.length-1];
nums = temp;
}
System.out.println(Arrays.toString(nums));
}
public static void main(String[] args) {
Code_189 code_189 = new Code_189();
int[] nums = new int[]{1,2,3,4,5,6,7};
code_189.rotate(nums, 3);
System.out.println(Arrays.toString(nums));
}
}