Using the Java Math class, we can implement methods like min(), max(), avg(), sin(), cos(), tan(), round(), ceil(), floor(), abs(), pow(), floor(), round() etc.

Math class in Java

Several times we need to perform some mathematical functions in our program. Sometimes we can create separate methods for the same, but while making large and complex problems, we do not have time for doing so. So, to implement these functions in our program, we can use the methods already defined in the Math class (which is present inside the java.lang.Math package).

Importing Math Class

If we want to import Math class in java, we have to write the following code.

java.lang.math

#java #java math

Math class in Java Example | Java Math Class Tutorial
3.85 GEEK