package shuzu;import java.util.*;public class Demo05 {public static void main(String []args){//定义一个数组int [] ary ={1,2,3,4,5};//扩容后的ary数组 ary = arryCopy(ary);//输出该数组System.out.println(Arrays.toString(ary));}/** * 扩容数组的方法。 */public static int[] arryCopy(int []ary){ary = Arrays.copyOf(ary, ary.length+1);ary[ary.length-1]= 8;return ary;}}
数组扩容
最新推荐文章于 2024-01-02 09:25:21 发布