zoukankan      html  css  js  c++  java
  • 反射之------获得运行时类的方法(非指定)

    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);
            }
    
    
        }
    }
    迎风少年
  • 相关阅读:
    DAY 179 在Flask中使用MongoDB:Flask-MongoEngine
    DAY 178 oracle基础
    DAY 177 mongoengine
    DAY 176 redis教程
    存储器
    cpu
    java 类文件类型
    线程池
    CopyOnWrite容器
    ConcurrentHashMap
  • 原文地址:https://www.cnblogs.com/ZYH-coder0927/p/13784461.html
Copyright © 2011-2022 走看看