package reflection;import java.lang.reflect.Constructor;
class Customer {
private String account;
private String password;
//两个构造器:
public Customer() {
System.out.println("Customer's Constructor");
}
public Customer(String account,String password) {
this.account = account;
this.password = password;
}
public Customer(String account,String password,int id) {

}
public void printInfo() {
System.out.println(account + " " + password);
}
}public class CustomerTest { public static void main(String[] args) throws Exception{
//! String str = "Customer";
//! str customer = new str();

//通过Class类获得实例
String className = "reflection.Customer";
Class c = Class.forName(className);

//得到类的构造器
Constructor[] cons = c.getConstructors();

/*for(Constructor conss : cons) {
System.out.println(conss.getName());
Class[] c1 = conss.getParameterTypes();
for(Class cc : c1) {
System.out.println(cc.getName());
}
}*/
for(int i = 0; i < cons.length; i++) {
//得到构造器的名称
System.out.println("第" + i + "个" +cons[i].getName());

//得到构造器中的参数列表
Class[] conss = cons[i].getParameterTypes();
for(int j = 0; j < conss.length; j++) {
//得到参数名称
System.out.println("第" + i + "个的第" + j + "个" + conss[j].getName());
}
}
}
}Output:
第0个polymorphism.Customer
第0个的第0个java.lang.String
第0个的第1个java.lang.String
第1个polymorphism.Customer
第1个的第0个java.lang.String
第1个的第1个java.lang.String
第1个的第2个int
第2个polymorphism.Customer我想请问为什么默认构造器被放在了最下面?