Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.Arrays; public class Main { /** * Concatenates a list of int arrays into a single array. * * @param arrays The arrays. * @return The concatenated array. * * @see {@link http://stackoverflow.com/questions/80476/how-to-concatenate-two-arrays-in-java} */ public static int[] concatAllInt(int[]... arrays) { int totalLength = 0; final int subArrayCount = arrays.length; for (int i = 0; i < subArrayCount; ++i) { totalLength += arrays[i].length; } int[] result = Arrays.copyOf(arrays[0], totalLength); int offset = arrays[0].length; for (int i = 1; i < subArrayCount; ++i) { System.arraycopy(arrays[i], 0, result, offset, arrays[i].length); offset += arrays[i].length; } return result; } }