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