/**
来 自
nowjava.com - 时 代 Java
**/
//package com.nowjava;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
public class Main {
public static void main(String[] argv) throws Exception {
Class classInstance = String.class;
getClassDeclaredFields(classInstance);
}
public static void getClassDeclaredFields(Class<?> classInstance) {
Field[] ff = classInstance.getDeclaredFields();
String x;
/*
来 自*
n o w j a v a . c o m - 时 代 Java
*/
for (int i = 0; i < ff.length; i++) {
x = ff[i].getType().getName();
System.out.println("???????:" + x);
}
System.out.println("----------------------------=");
Constructor<?>[] cn = classInstance.getDeclaredConstructors();
for (int i = 0; i < cn.length; i++) {
Class cx[] = cn[i].getParameterTypes();
System.out.println("???? :" + cn[i].getName());
for (int j = 0; j < cx.length; j++) {
x = cx[j].getName();
System.out.println("---------???? ?????? :" + x);
}
}
System.out.println("----------------------------=");
Method[] mm = classInstance.getDeclaredMethods();
for (int i = 0; i < mm.length; i++) {
System.out.println("????? :" + mm[i].getName());
int md = mm[i].getModifiers();
System.out.print("??? :" + Modifier.toString(md));
Class cx[] = mm[i].getParameterTypes();
for (int j = 0; j < cx.length; j++) {
/**代码未完, 请加载全部代码(NowJava.com).**/
本文系作者在时代Java发表,未经许可,不得转载。如有侵权,请联系nowjava@qq.com删除。