通过反射 根据指定类名创建对象 带参 不带参

1、不带参数的情况 首先得到该类的Class对象,再调用newInstance方法即可得到空参数列表的实例 public static void main(String[] args) throws Exception { Class c = Class.forName("com.nosuchmethod.Person"); //包名为com.nosuchmethod Method
相关文章
相关标签/搜索