java 数组浅拷贝与深拷贝
public class demo {
public void func(int[] nums) {
int[] tempNums = new int[]{1, 1, 1, 1, 1, 1};
// 浅拷贝
// nums = tempNums;
// 深拷贝
for(int j = 0; j < nums.length; j++){
nums[j] = tempNums[j];
}
}
@Test
public void main() {
int[] nums = new int[]{0, 0, 0 ,0 , 0, 0};
func(nums);
for (int num : nums) {
System.out.println(num);
}
}
}