/* from
时 代 Java 公 众 号 - nowjava.com*/
//package com.nowjava;
import java.lang.reflect.Array;
import java.util.Collection;
public class Main {
public static void main(String[] argv) {
Class type = String.class;
Collection collection = java.util.Arrays.asList("asdf",
"nowjava.com");
System.out.println(java.util.Arrays.toString(toArray(type,
collection)));
}
/**
* Converts a collection to a primitive array of a given type.
*
* @param type type of array to create
* @param collection collection to convert, must contain items that extend T
* @param <T> type of array to create
* @return primitive array of type T
*/
public static <T> T[] toArray(Class<T> type,
Collection<? extends T> collection) {
/*
来自
*N o w J a v a . c o m*/
/**代码未完, 请加载全部代码(NowJava.com).**/
本文系作者在时代Java发表,未经许可,不得转载。如有侵权,请联系nowjava@qq.com删除。