Can I Instantiate a class using the class object? What about Constructors?

后端 未结 6 758
时光说笑
时光说笑 2020-12-09 18:15

I am storing a list of classes through (Classname.class) and would like to instantiate one? Is this possible?

newInstance seems to the met

6条回答
  •  情歌与酒
    2020-12-09 19:01

    If you have a list of Class objects obtained through class literals, you might as well statically reference the constructors rather than slipping into reflection evilness.

提交回复
热议问题