java - instantiate class from class object -
In Java, can I use a class object to start dynamically those types of classes?
i.e. I need some functions like this.
object foo (class type) {// returns new object type 'type'}
You can use:
throws the object foo (class type) InstantiationException, IllegalAccessException {return type.newInstance (); }
... but it assumes that the zero-logic constructor is to go through a more robust route or, which takes you into using the reflection stuff in the package.
Comments
Post a Comment