I'm new in JAVA I'm trying to learn reflection I want to get specific constructor(picking the example form here) from my class :
public class example1 {
public example1() {
}
public example1(int i4) {
}
public example1(String s3) {
System.out.println("using param =" + s3);
}
public String s1;
public String s2;
public int i1;
public int i2;
public Object o1;
public Object o2;
public static void main(String[] args) {
Class<example1> examTesting = example1.class;
String examTestingname = examTesting.getName();
System.out.println("class name =" + (new example1()).getClass().getName());
Class<?> [] paramTypes = String.class.getClasses();
Constructor<example1> ctor = examTesting.getConstructor(paramTypes);
}
}
I get NoSuchMethodException
when trying to instantiate ctor
What am I missing here ?
Aucun commentaire:
Enregistrer un commentaire