Example usage for java.util List toArray

List of usage examples for java.util List toArray

Introduction

In this page you can find the example usage for java.util List toArray.

Prototype

<T> T[] toArray(T[] a);

Source Link

Document

Returns an array containing all of the elements in this list in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array.

Usage

From source file:Main.java

public static String[] toArray(List<String> list) {
    return list.toArray(new String[list.size()]);
}

From source file:Main.java

public static <T> T[] list2Array(List<T> oList) {
    Object[] oArray = oList.toArray(new Object[] {});
    T[] ts = (T[]) oArray;//w w w.  j  av  a2s .  c om
    return ts;
}

From source file:Main.java

@SuppressWarnings("unchecked")
public static <T> T[] toArray(List<T> list, Class<T> clazz) {
    return list.toArray((T[]) Array.newInstance(clazz, list.size()));
}

From source file:Main.java

public static String[] toArray(final List<String> values) {
    return values.toArray(new String[values.size()]);
}

From source file:Main.java

public static String[] fromList(List<String> list) {
    return list == null ? null : list.toArray(new String[list.size()]);
}

From source file:com.naver.template.common.ChunkUtils.java

public static long[] toPrimitiveArray(List<Long> list) {
    Long[] array = list.toArray(new Long[0]);
    return ArrayUtils.toPrimitive(array);
}

From source file:Main.java

@SuppressWarnings("unchecked")
public static <E extends Object> E[] toArray(List<E> list, Class<E> clazz) {
    return list.toArray((E[]) Array.newInstance(clazz, list.size()));
}

From source file:Main.java

public static long[] toPrimitives(List<Long> objects) {
    return toPrimitives(objects.toArray(new Long[objects.size()]));
}

From source file:Main.java

public static <T> T[] toArray(List<T> list, Class<T> cls) {
    return (T[]) list.toArray(createArray(cls, list.size()));
}

From source file:Main.java

public static String[] toStrArray(List<String> arrList) {
    String[] r = new String[arrList.size()];
    arrList.toArray(r);
    return r;//from  ww w.ja va 2 s. c o m
}