Here you can find the source of concatArrays(final char[] first, final char[]... rest)
Parameter | Description |
---|---|
first | array to concatenate. Cannot be null. |
rest | of the arrays to concatenate. May be null. |
public static char[] concatArrays(final char[] first, final char[]... rest)
//package com.java2s; /* See LICENSE for licensing and NOTICE for copyright. */ import java.util.Arrays; public class Main { /**/*from w w w. j av a2s . com*/ * Concatenates multiple character arrays together. * * @param first array to concatenate. Cannot be null. * @param rest of the arrays to concatenate. May be null. * * @return array containing the concatenation of all parameters */ public static char[] concatArrays(final char[] first, final char[]... rest) { int totalLength = first.length; for (char[] array : rest) { if (array != null) { totalLength += array.length; } } final char[] result = Arrays.copyOf(first, totalLength); int offset = first.length; for (char[] array : rest) { if (array != null) { System.arraycopy(array, 0, result, offset, array.length); offset += array.length; } } return result; } }