@Test public void testWithThreeArrays() { Object[] result = ArrayUtils.concatArrays(testArray(1, 2), testArray(3, 4, 5), testArray(6)); assertArrayEquals(testArray(1, 2, 3, 4, 5, 6), result); }
public static Object[] concatArrays(Object[]... arrays) { int length = 0; for (Object[] array: arrays) { length += array.length; } Object[] result = new Object[length]; int offset = 0; for (Object[] array: arrays) { System.arraycopy(array, 0, result, offset, array.length); offset += array.length; } return result; }
ArrayUtils { public static Object[] concatArrays(Object[]... arrays) { int length = 0; for (Object[] array: arrays) { length += array.length; } Object[] result = new Object[length]; int offset = 0; for (Object[] array: arrays) { System.arraycopy(array, 0, result, offset, array.length); offset += array.length; } return result; } }
ArrayUtils { public static Object[] concatArrays(Object[]... arrays) { int length = 0; for (Object[] array: arrays) { length += array.length; } Object[] result = new Object[length]; int offset = 0; for (Object[] array: arrays) { System.arraycopy(array, 0, result, offset, array.length); offset += array.length; } return result; } private  ArrayUtils(); }
ArrayUtils { public static Object[] concatArrays(Object[]... arrays) { int length = 0; for (Object[] array: arrays) { length += array.length; } Object[] result = new Object[length]; int offset = 0; for (Object[] array: arrays) { System.arraycopy(array, 0, result, offset, array.length); offset += array.length; } return result; } private  ArrayUtils(); static Object[] concatArrays(Object[]... arrays); }
ArrayUtils { public static Object[] concatArrays(Object[]... arrays) { int length = 0; for (Object[] array: arrays) { length += array.length; } Object[] result = new Object[length]; int offset = 0; for (Object[] array: arrays) { System.arraycopy(array, 0, result, offset, array.length); offset += array.length; } return result; } private  ArrayUtils(); static Object[] concatArrays(Object[]... arrays);  }