Here you can find the source of mergeArrays(Object[] first, Object[] second)
Parameter | Description |
---|---|
first | - The first Array. |
second | - The Second Array. |
public static Object[] mergeArrays(Object[] first, Object[] second)
//package com.java2s; /****************************************************************************** * * AniDBCmdC version 1.0 - AniDB client in Java * Copyright (C) 2005 ExElNeT//from w w w . ja v a2 s . c om * All Rights Reserved * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * E-mail: exelnet@web.de * *******************************************************************************/ public class Main { /** * Merges two Array to one. * * @param first - * The first Array. * @param second - * The Second Array. * @return - A new Array from thos merged Arrays: Warning: You must cast * every single Object inside the array to your class. */ public static Object[] mergeArrays(Object[] first, Object[] second) { if (first != null && second == null) return first; if (first == null && second != null) return second; if (first != null && second != null) { int size = first.length + second.length; Object[] newObjectArray = new Object[size]; for (int i = 0; i < first.length; i++) newObjectArray[i] = first[i]; for (int i = 0; i < second.length; i++) newObjectArray[first.length + i] = second[i]; return newObjectArray; } return null; } }