foreach历遍方法可以给数组赋值吗?
比如:
public int[] getArray(int length) {
int[] nums = new int[length];
for (int num: nums ) {
num = (int)(Math.random()*100);
}
return nums;
}
比如:
public int[] getArray(int length) {
int[] nums = new int[length];
for (int num: nums ) {
num = (int)(Math.random()*100);
}
return nums;
}
2018-09-25
举报