package com.Summer_0420.cn; import java.util.Arrays; /** * @author Summer * 我们使用数组存储了50名学生的考试信息 , 今天又增加了三名同学 , 请扩大存储介质 , 足以存储53名学生信息 */ public class TestMethod06 { static int [] score = new int[50]; public static void main(String[] args) { addScore(); } private static void addScore() { for (int i = 0; i < score.length; i++) { score[i] =(int) (Math.random()*101); } System.out.println(Arrays.toString(score)); int [] sc = Arrays.copyOf(score, score.length+3); System.out.println(Arrays.toString(sc)); } }
转载于:https://www.cnblogs.com/summerdata/p/10743127.html
最后
以上就是矮小百合最近收集整理的关于copyOf数组复制方法的使用(数组扩容练习)的全部内容,更多相关copyOf数组复制方法内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复