Using reflection in Java to create a new instance with the reference variable type set to the new instance class name?

后端 未结 6 1254
忘掉有多难
忘掉有多难 2020-12-03 03:30

All the examples I look at for reflection show creating a new instance of an unknown implementation, and casting that implementation to it\'s interface. The issue with this

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-03 03:53

    If you knew the Class of ImplementationType you could create an instance of it. So what you are trying to do is not possible.

提交回复
热议问题