Java Array to List fromArray(T[] array, Class clazz)

Here you can find the source of fromArray(T[] array, Class clazz)

Description

from Array

License

Open Source License

Declaration

public static <C extends Collection<T>, T> Collection<T> fromArray(T[] array, Class<C> clazz) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.Collection;

public class Main {
    public static <C extends Collection<T>, T> Collection<T> fromArray(T[] array, Class<C> clazz) {
        try {/*w  w  w  .  j  av a2s. co  m*/
            Collection<T> collection = clazz.newInstance();
            for (T o : array) {
                collection.add(o);
            }
            return collection;
        } catch (Exception e) {
            return null;
        }
    }
}

Related

  1. fromArray(final Object[][] array)
  2. fromArray(Object array[])
  3. fromArray(Object[] array)
  4. fromArray(T array[])
  5. fromArray(T... array)
  6. fromArray(T[] objects)
  7. newList(final T... elements)
  8. newList(final T... elements)
  9. newList(int... sizes)