首页 > 其他 > 详细

反射之------获得运行时类的方法(非指定)

时间:2020-10-09 11:50:47      阅读:62      评论:0      收藏:0      [点我收藏+]
package com.heima.userJSTL;

import java.lang.reflect.Method;

public class PersomTestMethod {
    public static void main(String[] args) {
        Class<Person> aClass = Person.class;
        Method[] methods = aClass.getMethods();//获取运行时类及其所有父类的所有被public修饰的方法
        for (Method method : methods) {
            System.out.println(method);
        }
        System.out.println("===================");
        Method[] declaredMethods = aClass.getDeclaredMethods();//getDeclaredMethods();获取当前运行时类的所有方法(不包括父类的方法)
        for (Method declaredMethod : declaredMethods) {
            System.out.println(declaredMethod);
        }


    }
}

 

反射之------获得运行时类的方法(非指定)

原文:https://www.cnblogs.com/ZYH-coder0927/p/13784461.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!