Java Array Concatenate concatArray(T[] first, T[]... rest)

Here you can find the source of concatArray(T[] first, T[]... rest)

Description

concat Array

License

Apache License

Declaration

public static <T> T[] concatArray(T[] first, T[]... rest) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.Arrays;

public class Main {
    public static <T> T[] concatArray(T[] first, T[]... rest) {
        int totalLength = first.length;
        for (T[] array : rest) {
            totalLength += array.length;
        }/*from   ww w .  j  a v a  2s .com*/
        T[] result = Arrays.copyOf(first, totalLength);
        int offset = first.length;
        for (T[] array : rest) {
            System.arraycopy(array, 0, result, offset, array.length);
            offset += array.length;
        }
        return result;
    }
}

Related

  1. concatArray(Object[] arr1, Object newValue)
  2. concatArray(String string, String[] words)
  3. concatArray(String[] array, int start)
  4. concatArray(String[] array, int start, String def)
  5. concatArray(String[] array, String glue)
  6. concatArrays(byte[] a, byte[] b)
  7. concatArrays(byte[]... arrays)
  8. concatArrays(byte[]... arrays)
  9. concatArrays(byte[]... byaArrays)