Java基础-反射应用

反射基本应用

反射进行对象实例化

在JDK1.8及以前的实例化:

1
2
@Deprecated(since="9")
public T newInstance() throws InstantiationException, IllegalAccessException

在JDK1.9+的实例化:

1
clazz.getDeclaredConstructor().newInstance()
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×