“`” 考察点:类

– 方法1:通过类对象调用newInstance()方法,例如:String.class.newInstance()
– 方法2:通过类对象的getConstructor()或getDeclaredConstructor()方法获得构造器(Constructor)对象并调用其newInstance()方法创建对象,例如:String.class.getConstructor(String.class).newInstance(""Hello"");

<pre><code> "“`

Was this helpful?

0 / 0

发表回复 0

Your email address will not be published.