Here you can find the source of flattenArray(Object... objects)
public static Object[] flattenArray(Object... objects)
//package com.java2s; /******************************************************************************* * Copyright (c) 2014 Gabriel Skantze./*from www.jav a2 s .c om*/ * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Public License v3.0 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/gpl.html * * Contributors: * Gabriel Skantze - initial API and implementation ******************************************************************************/ import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Main { public static Object[] flattenArray(Object... objects) { List result = new ArrayList(); for (Object obj : objects) { if (obj instanceof Object[]) { result.addAll(Arrays.asList((Object[]) obj)); } else if (obj instanceof List) { result.addAll((List) obj); } else { result.add(obj); } } return result.toArray(); } }