public Score(int[] scores) {
// 复制数组的办法Arrays中的方法赋值
// Arrays.copyOf(scores, scores.length);
// 直接克隆一个scores.clone();
// 本质上是将传入的数组对象内容赋给新的数组
int [] scoreCopy = new int[scores.length];
for (int i = 0; i < scores.length; i++) {
scoreCopy[i]=scores[i];
}
this.scores = scoreCopy;
this.scores = new int[scores.length];
this.scores[i]=scores[i];
这一节的练习在哪里呢?
Sign in to make a reply
王羲之666666
public Score(int[] scores) {
// 复制数组的办法Arrays中的方法赋值
// Arrays.copyOf(scores, scores.length);
// 直接克隆一个scores.clone();
// 本质上是将传入的数组对象内容赋给新的数组
int [] scoreCopy = new int[scores.length];
for (int i = 0; i < scores.length; i++) {
scoreCopy[i]=scores[i];
}
this.scores = scoreCopy;
}