When I want to use the mathematical methods in Java like abs
acos
I have to put it like this: Math.abs(int a)
, Math.acos(double a)
.
But what does it really mean?
Is Math
the name of the class or some object? How does it work?
When I want to use the mathematical methods in Java like abs
acos
I have to put it like this: Math.abs(int a)
, Math.acos(double a)
.
But what does it really mean?
Is Math
the name of the class or some object? How does it work?
Math class has static methods. So you can invoke it like:
int absolute = Math.abs(-123);
// absolute now has +123
A static method can be invoked without creating an instance of a class.
The class Math contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric functions.
https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html