通過反射 根據指定類名創建對象 帶參 不帶參

1、不帶參數的情況 首先得到該類的Class對象,再調用newInstance方法即可得到空參數列表的實例 public static void main(String[] args) throws Exception { Class c = Class.forName("com.nosuchmethod.Person"); //包名爲com.nosuchmethod Method
相關文章
相關標籤/搜索