Display the declared methods of java.lang.Math

Java 8Object Oriented ProgrammingProgramming

The methods of the java.lang.Math class can be listed using the java.lang.Class.getDeclaredMethods() method. 

This method returns an array that contains all the Method objects with public, private, protected and default access. However, the inherited methods are not included. Also, the getDeclaredMethods() method returns a zero length array if the class or interface has no methods or if a primitive type, array class or void is represented in the Class object.

A program that demonstrates this is given as follows −

Example

 Live Demo

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\n");
      for (int i = 0; i < methods.length; i++) {
         System.out.println("The method is: " + methods[i]);
      }
   }
}

Output

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)
raja
Published on 09-Jan-2019 11:44:31
Advertisements