Math class in Java

Math class is defined inside the package java.lang .

It is used to perform mathematical operations easily and effectively. We can perform trigonometrical operations, square root, cube root, logarithmic and comparison of mathematical values very easily using the methods of this class.

Available variables or fields in Math class

public static final double E=2.718281828459045

It represents the base of natural logarithm e value. We can directly use the variable where we need to apply e value.

public static final double PI=3.141592653589793

It can be used to represent pi value and can be directly used where we need to apply pi value.

Available methods in Math class