提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
按大小创建新数组
//package com.book2s; import java.lang.reflect.Array;/** 来自 nowjava**/ public class Main { public static void main(String[] argv) { Class componentType = String.class; int newSize = 42; System.out.println(java.util.Arrays.toString(newArray( componentType, newSize))); } @SuppressWarnings("unchecked") /* from N o w J a v a . c o m*/ public static <T> T[] newArray(Class<?> component