提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
创建新实例
/** from nowjava.com - 时 代 Java**/ //package com.nowjava; public class Main { public static void main(String[] argv) throws Exception { Class cls = String.class; System.out.println(newInstance(cls)); } public static Object newInstance(Class<?> cls) { Object obj = null; try { obj = cls.newInstance(); /** 来 自 时 代 J a v a - N o w J a v a . c o m **/ } catch (InstantiationException e) { e.printStackTrace(); }