All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openforis.commons.collection.ArrayUtils Maven / Gradle / Ivy

package org.openforis.commons.collection;

import java.lang.reflect.Array;

/**
 * 
 * @author S. Ricci
 *
 */
public class ArrayUtils {

	public static  T[] join(Class type, T[]... arrays) {
		int totalLenght = 0;
		for (T[] arr : arrays) {
			totalLenght += arr.length;
		}
		@SuppressWarnings("unchecked")
		T[] result = (T[]) Array.newInstance(type, totalLenght);
		int currPos = 0;
		for (T[] arr : arrays) {
			System.arraycopy(arr, 0, result, currPos, arr.length);
			currPos += arr.length;
		}
		return result;
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy