Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

public class Main {
    public static <T> T[] concat(T[] first, T[] second) {
        if (first == null && second == null) {
            return null;
        } else if (first == null) {
            return Arrays.copyOf(second, second.length);
        } else if (second == null) {
            return Arrays.copyOf(first, first.length);
        } else {
            T[] result = Arrays.copyOf(first, first.length + second.length);
            System.arraycopy(second, 0, result, first.length, second.length);
            return result;
        }
    }
}