zoukankan      html  css  js  c++  java
  • 2- 获取类的方法以及变量

    获取类的方法以及变量

    • getMethods 获取默认方法,包括父类Object的

    mark

    public java.lang.String com.xieth.jdkeight.domain.Person.toString()
    public java.lang.String com.xieth.jdkeight.domain.Person.getName()
    public void com.xieth.jdkeight.domain.Person.setName(java.lang.String)
    public void com.xieth.jdkeight.domain.Person.setAge(int)
    public int com.xieth.jdkeight.domain.Person.getAge()
    public java.lang.String com.xieth.jdkeight.domain.Person.getStr()
    public void com.xieth.jdkeight.domain.Person.sao()
    public void com.xieth.jdkeight.domain.Person.sao(java.lang.String)
    public void com.xieth.jdkeight.domain.Person.setStr(java.lang.String)
    public final void java.lang.Object.wait() throws java.lang.InterruptedException
    public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException
    public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException
    public boolean java.lang.Object.equals(java.lang.Object)
    public native int java.lang.Object.hashCode()
    public final native java.lang.Class java.lang.Object.getClass()
    public final native void java.lang.Object.notify()
    public final native void java.lang.Object.notifyAll()
    
    • getDeclaredMethods获取自身的方法,不包括父类的

    mark

    public java.lang.String com.xieth.jdkeight.domain.Person.toString()
    public java.lang.String com.xieth.jdkeight.domain.Person.getName()
    public void com.xieth.jdkeight.domain.Person.setName(java.lang.String)
    public int com.xieth.jdkeight.domain.Person.getAge()
    public void com.xieth.jdkeight.domain.Person.sao()
    public void com.xieth.jdkeight.domain.Person.sao(java.lang.String)
    public java.lang.String com.xieth.jdkeight.domain.Person.getStr()
    public void com.xieth.jdkeight.domain.Person.setAge(int)
    public void com.xieth.jdkeight.domain.Person.setStr(java.lang.String)
    
    • getFields 获取public级别的变量,设置值并输出

    mark

    collect = [public java.lang.String com.xieth.jdkeight.domain.Person.str]
    obj = sss
    
    • getDeclaredFields 获取所有变量

    mark

    collect = [private java.lang.String com.xieth.jdkeight.domain.Person.name, public java.lang.String com.xieth.jdkeight.domain.Person.str]
    obj = sss
    obj = sss
    
  • 相关阅读:
    echarts图形的位置布局如何调整
    IDEA在写springboot项目的时候遇见的问题:Caused by: java.lang.NoClassDefFoundError: com/fasterxml/classmate/TypeResol
    【学习总结】linux命令:ps -ef | grep xxxserver | grep -v grep|wc -l
    linux中管道符“|”的作用 find的作用
    linux系统中的管道“|”命令的作用
    JDBC管理事务
    SQL注入的问题&使用PreparedStatement对象防止SQL注入
    JDBC对象详解DriverManager&Connection&Statement
    MySQL安装&使用DataGrip连接数据库
    红黑树(R-B树,对称二叉B树)
  • 原文地址:https://www.cnblogs.com/xietianhua/p/11342564.html
Copyright © 2011-2022 走看看