Java examples for Collection Framework:Array Length
expand Array's length
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { int[] data = new int[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 }; int size = 2; System.out.println(java.util.Arrays .toString(expandArray(data, size))); }//from w w w. ja v a2s . co m public static int[] expandArray(int[] data, int size) { int length = data.length; int[] copy = new int[length + size]; System.arraycopy(data, 0, copy, 0, Math.min(length, copy.length)); return copy; } }