[Java] 动态调整数组长度 →→→→→进入此内容的聊天室

来自 , 2019-05-12, 写在 Java, 查看 132 次.
URL http://www.code666.cn/view/08b255a5
  1.         public static Integer[] increase(Integer[] src, int length) {
  2.                 if (src == null) {
  3.                         return null;
  4.                 }
  5.                 // 新建一个数组,长度为旧数组的长度加上length
  6.                 Integer[] result = new Integer[src.length + length];
  7.                 // 新数组的前面部分的值与旧数组的值一样
  8.                 // 这是一种常用的拷贝数组的方法
  9.                 System.arraycopy(src, 0, result, 0, src.length);
  10.                 return result;
  11.         }

回复 "动态调整数组长度"

这儿你可以回复上面这条便签

captcha