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);
}
}
}
标签:java,tempNums,nums,int,数组,拷贝,public From: https://www.cnblogs.com/ReturnOfTheKing/p/17795641.html