Java Array Concatenate concat(T[]... tss)

Here you can find the source of concat(T[]... tss)

Description

concat

License

Open Source License

Declaration

public static <T> T[] concat(T[]... tss) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.*;

public class Main {

    public static <T> T[] concat(T[]... tss) {
        int length = 0;
        for (T[] ts : tss)
            length += ts.length;/*  w w  w  .  j  a  v a  2  s. co  m*/
        T[] res = Arrays.copyOf(tss[0], length);
        for (int i = 1, p = tss[0].length; i < tss.length; p += tss[i++].length) {
            System.arraycopy(tss[i], 0, res, p, tss[i].length);
        }
        return res;
    }
}

Related

  1. concat(T[] first, T[]... rest)
  2. concat(T[] head, T... tail)
  3. concat(T[] left, T[] right)
  4. concat(T[] objects)
  5. concat(T[]... arrays)
  6. concatAll(byte[] a, byte[]... rest)
  7. concatAll(byte[] first, byte[]... rest)
  8. concatAll(byte[]... args)
  9. concatAll(T[] first, T[]... rest)