Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    /**
     * Works with two arrays of the same class type.
     * 
     * @param a
     * @param b
     * @return
     */
    public static <T> T[] concatArrays(T[] a, T[] b) {
        final int alen = a.length;
        final int blen = b.length;
        @SuppressWarnings("unchecked")
        final T[] result = (T[]) java.lang.reflect.Array.newInstance(a.getClass().getComponentType(), alen + blen);
        System.arraycopy(a, 0, result, 0, alen);
        System.arraycopy(b, 0, result, alen, blen);
        return result;
    }
}