Java tutorial
//package com.java2s; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Enumeration; import java.util.List; import java.util.Map; public class Main { public static <V> List<V> uniteCollectionArray(Collection<V[]> values) { if (isEmpty(values)) { return Collections.emptyList(); } List<V> copy = new ArrayList<V>(); for (V[] collections : values) { copy.addAll(Arrays.asList(collections)); } return copy; } public static boolean isEmpty(Map<?, ?> test) { return !isNotEmpty(test); } public static boolean isEmpty(Collection<?> test) { return !isNotEmpty(test); } public static boolean isEmpty(Object[] test) { return !isNotEmpty(test); } public static <V> List<V> asList(Enumeration<V> elements) { if (elements == null || !elements.hasMoreElements()) { return Collections.emptyList(); } List<V> copy = new ArrayList<V>(); for (; elements.hasMoreElements();) { copy.add(elements.nextElement()); } return copy; } public static <E> List<E> asList(E... elements) { if (elements == null || elements.length == 0) { return Collections.emptyList(); } // Avoid integer overflow when a large array is passed in int capacity = (int) Math.min(5L + elements.length + (elements.length / 10), Integer.MAX_VALUE); ArrayList<E> list = new ArrayList<E>(capacity); Collections.addAll(list, elements); return list; } public static boolean isNotEmpty(Map<?, ?> test) { return test != null && !test.isEmpty(); } public static boolean isNotEmpty(Collection<?> test) { return test != null && !test.isEmpty(); } public static boolean isNotEmpty(Object[] test) { return test != null && test.length > 0; } }