显示 java.lang.Math 的已声明方法
使用 java.lang.Class.getDeclaredMethods() 方法,可以列出 java.lang.Math 类的所有方法。
此方法将返回一个数组,数组中包括所有公共的、私有的、受保护的和默认的所有 Method 对象。但是,不包括继承的方法。另外,如果类或接口没有方法,或者在 Class 对象中表示了基本类型、数组类或 void,则 getDeclaredMethods() 方法将返回一个长度为 0 的数组。
以下是演示此方法的程序 −
例如
import java.lang.reflect.Method;
public class Demo {
public static void main(final String[] args) {
final Method[] methods = Math.class.getDeclaredMethods();
System.out.println("Methods of java.lang.Math Class
");
for (int i = 0; i < methods.length; i++) {
System.out.println("The method is: " + methods[i]);
}
}
}输出
Methods of java.lang.Math Class The method is: public static int java.lang.Math.abs(int) The method is: public static double java.lang.Math.abs(double) The method is: public static float java.lang.Math.abs(float) The method is: public static long java.lang.Math.abs(long) The method is: public static double java.lang.Math.sin(double) The method is: public static double java.lang.Math.cos(double) The method is: public static double java.lang.Math.tan(double) The method is: public static double java.lang.Math.atan2(double,double) The method is: public static double java.lang.Math.sqrt(double) The method is: public static double java.lang.Math.log(double) The method is: public static double java.lang.Math.log10(double) The method is: public static double java.lang.Math.pow(double,double) The method is: public static double java.lang.Math.exp(double) The method is: public static long java.lang.Math.min(long,long) The method is: public static double java.lang.Math.min(double,double) The method is: public static float java.lang.Math.min(float,float) The method is: public static int java.lang.Math.min(int,int) The method is: public static double java.lang.Math.max(double,double) The method is: public static float java.lang.Math.max(float,float) The method is: public static long java.lang.Math.max(long,long) The method is: public static int java.lang.Math.max(int,int) The method is: public static long java.lang.Math.addExact(long,long) The method is: public static int java.lang.Math.addExact(int,int) The method is: public static long java.lang.Math.decrementExact(long) The method is: public static int java.lang.Math.decrementExact(int) The method is: public static long java.lang.Math.incrementExact(long) The method is: public static int java.lang.Math.incrementExact(int) The method is: public static int java.lang.Math.multiplyExact(int,int) The method is: public static long java.lang.Math.multiplyExact(long,long) The method is: public static long java.lang.Math.negateExact(long) The method is: public static int java.lang.Math.negateExact(int) The method is: public static int java.lang.Math.subtractExact(int,int) The method is: public static long java.lang.Math.subtractExact(long,long) The method is: public static double java.lang.Math.scalb(double,int) The method is: public static float java.lang.Math.scalb(float,int) The method is: public static float java.lang.Math.copySign(float,float) The method is: public static double java.lang.Math.copySign(double,double) The method is: public static int java.lang.Math.getExponent(double) The method is: public static int java.lang.Math.getExponent(float) The method is: public static double java.lang.Math.signum(double) The method is: public static float java.lang.Math.signum(float) The method is: public static double java.lang.Math.asin(double) The method is: public static double java.lang.Math.acos(double) The method is: public static double java.lang.Math.atan(double) The method is: public static double java.lang.Math.toRadians(double) The method is: public static double java.lang.Math.toDegrees(double) The method is: public static double java.lang.Math.cbrt(double) The method is: public static double java.lang.Math.IEEEremainder(double,double) The method is: public static double java.lang.Math.ceil(double) The method is: public static double java.lang.Math.floor(double) The method is: public static double java.lang.Math.rint(double) The method is: public static long java.lang.Math.round(double) The method is: public static int java.lang.Math.round(float) The method is: public static double java.lang.Math.random() The method is: public static int java.lang.Math.toIntExact(long) The method is: public static int java.lang.Math.floorDiv(int,int) The method is: public static long java.lang.Math.floorDiv(long,long) The method is: public static int java.lang.Math.floorMod(int,int) The method is: public static long java.lang.Math.floorMod(long,long) The method is: public static float java.lang.Math.ulp(float) The method is: public static double java.lang.Math.ulp(double) The method is: public static double java.lang.Math.sinh(double) The method is: public static double java.lang.Math.cosh(double) The method is: public static double java.lang.Math.tanh(double) The method is: public static double java.lang.Math.hypot(double,double) The method is: public static double java.lang.Math.expm1(double) The method is: public static double java.lang.Math.log1p(double) The method is: public static double java.lang.Math.nextAfter(double,double) The method is: public static float java.lang.Math.nextAfter(float,double) The method is: public static double java.lang.Math.nextUp(double) The method is: public static float java.lang.Math.nextUp(float) The method is: public static double java.lang.Math.nextDown(double) The method is: public static float java.lang.Math.nextDown(float) The method is: static double java.lang.Math.powerOfTwoD(int) The method is: static float java.lang.Math.powerOfTwoF(int)
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP