List of utility methods to do Array to List
List | fromArray(E[] array) from Array if ((array == null) || (array.length == 0)) { return new ArrayList<E>(); return new ArrayList<E>(Arrays.asList(array)); |
Map | fromArray(final Object[][] array) from Array final Map<K, V> result = new HashMap<K, V>(); for (int i = 0; i < array.length; ++i) { final K key = (K) array[i][0]; final V value = (V) array[i][1]; result.put(key, value); return result; |
Set | fromArray(Object array[]) Create a set containing the elements of an array Set l = set(); for (int i = 0; i < array.length; i++) { l.add(array[i]); return l; |
List | fromArray(Object[] array) from Array if ((array == null) || (array.length == 0)) { return new ArrayList(); List list = new ArrayList(array.length); for (int i = 0; i < array.length; i++) { list.add(array[i]); return list; ... |
List | fromArray(T array[]) Create a list containing the elements of an array List<T> l = new ArrayList<T>(array.length); for (T o : array) { l.add(o); return l; |
List | fromArray(T... array) from Array return array != null ? Arrays.asList(array) : null;
|
Collection | fromArray(T[] array, Class from Array try { Collection<T> collection = clazz.newInstance(); for (T o : array) { collection.add(o); return collection; } catch (Exception e) { return null; ... |
ArrayList | fromArray(T[] objects) from Array ArrayList<T> arrayList = new ArrayList<T>(); Collections.addAll(arrayList, objects); return arrayList; |
List | newList(final T... elements) Returns a List with a initial capacity which equals to the number of elements given in parameter and with those elements already added. final List<T> retval = new ArrayList<T>(elements.length); Collections.addAll(retval, elements); return retval; |
List | newList(final T... elements) new List final ArrayList<T> list = new ArrayList<>(); for (final T element : elements) { list.add(element); return list; |