[Java反射机制] 运行期间获取任意类的所有方法声明

关于反射机制的定义

案例无意义、仅仅演示反射机制的初步印象

import java.lang.reflect.Method;

public class ReflectionDemo01 {
public static void main(String[] args) throws Exception {
Class<?> classType = Class.forName("java.lang.Integer");

Method[] methods = classType.getDeclaredMethods();
for (Method method : methods)
System.out.println(method);
}
}



My New Blog : http://blog.fdlife.info/ The more you know, the less you believe.
原文地址:https://www.cnblogs.com/ForDream/p/2324017.html