getmethods

类的类getMethods()方法 (Class class getMethods() method)

  • getMethods() method is available in java.lang package.

    getMethods()方法在java.lang包中可用。

  • getMethods() method is used to return an array of Method objects that indicate all the public methods of the class or interfaces along with it includes all inherited public methods from parent classes or parent interfaces.

    getMethods()方法用于返回一个Method对象数组,这些对象指示该类或接口的所有公共方法,以及它包括从父类或父接口继承的所有公共方法。

  • getMethods() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.

    getMethods()方法是一个非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。

  • getMethods() method may throw an exception at the time of returning an array of Method objects.

    getMethods()方法在返回Method对象数组时可能会引发异常。

    SecurityException: In this exception, it may raise when the security manager exists.

    SecurityException :在此异常中,当安全管理器存在时可能会引发此异常。

Syntax:

句法:

    public Method[] getMethods();

Parameter(s):

参数:

  • It does not accept any parameter.

    它不接受任何参数。

Return value:

返回值:

The return type of this method is Method[], it returns an array of Method object denoting all the public method of this class including all public inherited Methods represented by this Class object.

此方法的返回类型为Method [] ,它返回一个Method对象数组,该数组表示此类的所有公共方法,包括由此Class对象表示的所有公共继承的Method。

Note:

注意:

  • When class or interface does not contain public method, 0 is returned.

    当类或接口不包含公共方法时,将返回0。

  • When this class object holds primitive, an array class, or void type, 0 is returned.

    当此类对象包含基本类型,数组类或void类型时,将返回0。

Example:

例:

// Java program to demonstrate the example
// of Method[] getMethods ()
// method of Class
import java.lang.reflect.*;
public class GetMethodsOfClass {public static void main(String[] args) throws Exception {Thread th = new Thread();
// Get Class object of String
Class cl = th.getClass();
// Calling Thread Class Methods
Method[] methods = cl.getMethods();
for (int i = 0; i < methods.length; ++i) {System.out.print("String Class Methods = ");
System.out.println(methods[i].toString());
}
}
}

Output

输出量

String Class Methods = public void java.lang.Thread.run()
String Class Methods = public java.lang.String java.lang.Thread.toString()
String Class Methods = public boolean java.lang.Thread.isInterrupted()
String Class Methods = public static native java.lang.Thread java.lang.Thread.currentThread()
String Class Methods = public static void java.lang.Thread.onSpinWait()
String Class Methods = public final java.lang.String java.lang.Thread.getName()
String Class Methods = public final void java.lang.Thread.join() throws java.lang.InterruptedException
String Class Methods = public final synchronized void java.lang.Thread.join(long,int) throws java.lang.InterruptedException
String Class Methods = public final synchronized void java.lang.Thread.join(long) throws java.lang.InterruptedException
String Class Methods = public final java.lang.ThreadGroup java.lang.Thread.getThreadGroup()
String Class Methods = public void java.lang.Thread.setContextClassLoader(java.lang.ClassLoader)
String Class Methods = public java.lang.StackTraceElement[] java.lang.Thread.getStackTrace()
String Class Methods = public static native boolean java.lang.Thread.holdsLock(java.lang.Object)
String Class Methods = public final void java.lang.Thread.checkAccess()
String Class Methods = public static void java.lang.Thread.dumpStack()
String Class Methods = public final void java.lang.Thread.setPriority(int)
String Class Methods = public final void java.lang.Thread.setDaemon(boolean)
String Class Methods = public synchronized void java.lang.Thread.start()
String Class Methods = public static native void java.lang.Thread.yield()
String Class Methods = public static void java.lang.Thread.sleep(long,int) throws java.lang.InterruptedException
String Class Methods = public static native void java.lang.Thread.sleep(long) throws java.lang.InterruptedException
String Class Methods = public final void java.lang.Thread.stop()
String Class Methods = public void java.lang.Thread.interrupt()
String Class Methods = public static boolean java.lang.Thread.interrupted()
String Class Methods = public final native boolean java.lang.Thread.isAlive()
String Class Methods = public final void java.lang.Thread.suspend()
String Class Methods = public final void java.lang.Thread.resume()
String Class Methods = public final int java.lang.Thread.getPriority()
String Class Methods = public final synchronized void java.lang.Thread.setName(java.lang.String)
String Class Methods = public static int java.lang.Thread.activeCount()
String Class Methods = public static int java.lang.Thread.enumerate(java.lang.Thread[])
String Class Methods = public native int java.lang.Thread.countStackFrames()
String Class Methods = public final boolean java.lang.Thread.isDaemon()
String Class Methods = public java.lang.ClassLoader java.lang.Thread.getContextClassLoader()
String Class Methods = public static java.util.Map java.lang.Thread.getAllStackTraces()
String Class Methods = public long java.lang.Thread.getId()
String Class Methods = public java.lang.Thread$State java.lang.Thread.getState()
String Class Methods = public static void java.lang.Thread.setDefaultUncaughtExceptionHandler(java.lang.Thread$UncaughtExceptionHandler)
String Class Methods = public static java.lang.Thread$UncaughtExceptionHandler java.lang.Thread.getDefaultUncaughtExceptionHandler()
String Class Methods = public java.lang.Thread$UncaughtExceptionHandler java.lang.Thread.getUncaughtExceptionHandler()
String Class Methods = public void java.lang.Thread.setUncaughtExceptionHandler(java.lang.Thread$UncaughtExceptionHandler)
String Class Methods = public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException
String Class Methods = public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException
String Class Methods = public final void java.lang.Object.wait() throws java.lang.InterruptedException
String Class Methods = public boolean java.lang.Object.equals(java.lang.Object)
String Class Methods = public native int java.lang.Object.hashCode()
String Class Methods = public final native java.lang.Class java.lang.Object.getClass()
String Class Methods = public final native void java.lang.Object.notify()
String Class Methods = public final native void java.lang.Object.notifyAll()

翻译自: https://www.includehelp.com/java/class-class-getmethods-method-with-example.aspx

getmethods

getmethods_Java类类getMethods()方法及示例相关推荐

  1. java.util.zip 用法,Java压缩文件工具类ZipUtil使用方法代码示例

    本文实例通过Java的Zip输入输出流实现压缩和解压文件,前一部分代码实现获取文件路径,压缩文件名的更改等,具体如下: package com.utility.zip; import java.io. ...

  2. java long valueof_Java Long类的valueOf()方法及示例

    语法:public static Long valueOf (long value); public static Long valueOf (String value); public static ...

  3. Java基础篇:为Box类添加一个方法

    尽管创建一个仅包含数据的类是相当不错的事情,但这样的情况很少发生.大部分情况是你将使用方法存取由类定义的实例变量. 事实上,方法定义大多数类的接口.这允许类实现函数可以把内部数据结构的特定布局隐蔽到方 ...

  4. ulp通信_Java Math类ulp()方法及示例

    ulp通信 数学类ulp()方法 (Math class ulp() method) ulp() method is available in java.lang package. ulp()方法在j ...

  5. Java Math类toDegrees()方法与示例

    数学类toDegrees()方法 (Math class toDegrees() method) toDegrees() method is available in java.lang packag ...

  6. java 根据类名示例化类_Java类类getEnclosingClass()方法及示例

    java 根据类名示例化类 类的类getEnclosingClass()方法 (Class class getEnclosingClass() method) getEnclosingClass() ...

  7. java 根据类名示例化类_Java类类getProtectionDomain()方法及示例

    java 根据类名示例化类 类class getProtectionDomain()方法 (Class class getProtectionDomain() method) getProtectio ...

  8. java 根据类名示例化类_Java类类的requiredAssertionStatus()方法和示例

    java 根据类名示例化类 类的类requiredAssertionStatus()方法 (Class class desiredAssertionStatus() method) desiredAs ...

  9. java 根据类名示例化类_Java LocalDateTime类| ofInstant()方法与示例

    java 根据类名示例化类 LocalDateTime类的Instant()方法 (LocalDateTime Class ofInstant() method) ofInstant() method ...

最新文章

  1. python进度条 pyqt_Python高级进阶#015 pyqt5进度条QProgressBar结合使用qbasictimer
  2. android 是否允许打印debug级别日志的开关_log日志功能及设置方法
  3. mathtype批量修改公式的字体大小
  4. 在 C# 中,如何发现死锁并防止死锁
  5. 嵌入式成长轨迹53 【Zigbee项目】【CC2430基础实验】【串口时钟PC显示】
  6. unix/linux系统中文件分为哪些类型?,到底该如何理解 Unix/Linux 的文件系统?看这篇就知道了...
  7. golang for range原理(转载)
  8. mysql数据库版本常用_推荐:经典版本常用MySQL的命令集锦_MySQL
  9. 证明:$(g\circ f = e_X)\Rightarrow(g是满射)\wedge(f是单射)$
  10. AUTOCAD——命令重复、撤销与重做
  11. LED电子显示屏真彩显示的几种关键技术[转]
  12. 海信 Vidda Z100 评测
  13. 笔记1 第11课 贪心初步 ——柠檬水找零,分发饼干,跳跃游戏,完成所有任务所需最小能量——极客时间算法
  14. 微信服务器保留几年记录_企业微信朋友圈管理的工具
  15. HBuilderX 下载安装教程
  16. 计算机管理映像路径,win10系统任务管理器查看映像路径的详细方案
  17. matlab典型环节性能仿真,实验一典型环节的matlab仿真
  18. 陆琪众筹出书:一种读者视野的重新诠释_娱乐频道_红网
  19. Docker镜像原理及容器数据卷
  20. AV终结者病毒愈演愈烈

热门文章

  1. 蓝桥杯算法入门_26 (2015真题)
  2. View 的 onMeasure 方法
  3. 微信小程序单独设置右上角胶囊颜色
  4. lodop 报表套打分页、每页带有表头等【解决问题:每页底部最好一条数据显示不全、遗漏等问题】
  5. 色铅笔绘画入门(1)-了解色铅笔和其他绘画工具
  6. python自带笔记本电脑_Python内置常用模块
  7. 前锋mysql视频教程_mysql case then使用
  8. 算法题 推多米诺 模拟、队列与黑魔法
  9. FFmpeg crop裁剪原理记录一个bug
  10. 适合新手小白学习的web前端自学路线图整理