Here you can find the source of concat(int[] first, int[] second)
public static int[] concat(int[] first, int[] second)
//package com.java2s; /*//from ww w . j a v a2s . co m * #%L * G * %% * Copyright (C) 2014 Giovanni Stilo * %% * G is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this program. If not, see * <https://www.gnu.org/licenses/lgpl-3.0.txt>. * #L% */ import java.util.Arrays; public class Main { public static int[] concat(int[] first, int[] second) { if (first == null && second == null) { return new int[0]; } if (first == null) { return Arrays.copyOf(second, second.length); } if (second == null) { return Arrays.copyOf(first, first.length); } int[] result = Arrays.copyOf(first, first.length + second.length); System.arraycopy(second, 0, result, first.length, second.length); return result; } public static long[] concat(long[] first, long[] second) { if (first == null && second == null) { return new long[0]; } if (first == null) { return Arrays.copyOf(second, second.length); } if (second == null) { return Arrays.copyOf(first, first.length); } long[] result = Arrays.copyOf(first, first.length + second.length); System.arraycopy(second, 0, result, first.length, second.length); return result; } }