I have a class that takes a List in the constructor;
public class MyClass {
private List<Structure> structures;
public MyClass(List<Structure> structures) {
this.structures = structures;
}
}
that I need to instantiate via reflection. How do I define the call to class.getConstructor() to find this?
Regards
This should work:
Constructor<MyClass> constructor = MyClass.class.getConstructor(List.class);
or
Constructor constructor = MyClass.class.getConstructor(new Class[]{List.class});
for Java 1.4.x or less
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With