-
在java1.9版本中,**newInstance()**已经被弃用,取而代之的是
class.getDeclaredConstructor().newInstance()
class.newInstance()
会直接调用该类的无参构造函数进行实例化class.getDeclaredConstructor().newInstance()
getDeclaredConstructor()方法会根据他的参数对该类的构造函数进行搜索并返回对应的构造函数,没有参数就返回该类的无参构造函数,然后再通过newInstance进行实例化。