I need to use reflection in my code, so my program does not interrupt with every other version. I want to create a new instance of the class and the constructor that I want to use contains an array of the class. But this class must also be found using reflection. This is an example of what I have.
Constructor<?> constructor = getClass("className").getConstructor(getClass("anotherClass"));
private Class<?> getClass(String name) {
return Class.forName("my.package." + version + "." + name);
}
However, the constructor does not use this class, but an array of this class, so how would I turn this class into its array?
source
share