public static void main(String[] args) {
int [] scoreList = new int[5];
scoreList[0] = 68;
scoreList[1] = 78;
scoreList[2] = 88;
scoreList[3] = 98;
scoreList[4] = 58;

/*
*1: 创建新的数组。长度是原来的1.5倍。
*2:依次取出原来数组的元素。取出放到新数组里
*/
int [] newList = new int[7];

// for(int i:scoreList ) {
// newList[]= i;
// }
// for(int i =0;i<scoreList.length;i++) {
// newList[i] = scoreList[i];
// }

for(int i :newList) {
System.out.println(i);
}

System.arraycopy(scoreList, 0, newList, 0, 3);

for (int i : newList) {
System.out.println(i);
}




}
}

 posted on 2019-06-19 18:16  黑猫007  阅读(242)  评论(0编辑  收藏  举报