Generic method to concatenate two array - Java Collection Framework

Java examples for Collection Framework:Array Element

Description

Generic method to concatenate two array

Demo Code


//package com.java2s;
import java.util.Arrays;

public class Main {
    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;
    }//  w  w w .  j  a v a  2 s . c om
}

Related Tutorials