Java Array Concatenate concat(T[] first, T[] second)

Here you can find the source of concat(T[] first, T[] second)

Description

Concats two arrays in to one

License

Apache License

Parameter

Parameter Description
first array
second array

Return

unified array

Declaration

public static <T> T[] concat(T[] first, T[] second) 

Method Source Code


//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License");

import java.util.Arrays;

public class Main {
    /**//from www .  ja  v a  2 s .c  om
     * Concats two arrays in to one
     * 
     * @param first
     *            array
     * @param second
     *            array
     * 
     * @return unified array
     */
    public static <T> T[] concat(T[] first, T[] second) {
        T[] result = Arrays.copyOf(first, first.length + second.length);
        System.arraycopy(second, 0, result, first.length, second.length);
        return result;
    }
}

Related

  1. concat(T[] array1, T[] array2)
  2. concat(T[] array1, T[] array2)
  3. concat(T[] first, @SuppressWarnings("unchecked") T... second)
  4. concat(T[] first, T[] second)
  5. concat(T[] first, T[] second)
  6. concat(T[] first, T[] second)
  7. concat(T[] first, T[]... rest)
  8. concat(T[] head, T... tail)
  9. concat(T[] left, T[] right)