java-反射-构造函数的参数类型

代码 

package test;

import java.lang.reflect.Constructor;

public class ReflectTypeConstructor {

    public static void main(String[] args) {
	// TODO Auto-generated method stub
	System.out.println("反射-个类型的构造函数类型统计");
	ReflectTypeConstructor reflectTypeConstructor = new ReflectTypeConstructor();
	reflectTypeConstructor.mian();
    }
    public void mian(){
	System.out.print("复杂类型");
	display(Integer.class);
	display(Long.class);
	System.out.print("简单类型");
	display(int.class);
	display(long.class);
    }
    public void display(Class c){
	System.out.print("");
	System.out.println("名称:"+c.getName());
	Constructor cons[] = c.getConstructors();
	int indexfun = 1;
	for(Constructor con:cons){
	    System.out.println("函数名"+indexfun+++":"+con.getName());
	    Class contypes[] = con.getParameterTypes();
	    int index = 1;
	    for(Class cy:contypes){
		System.out.println("   参数"+index+++":"+cy.getName());
	    }
	}
    }

}

 

你可能感兴趣的:(java-编码笔记)