KaiquanMah's picture
Math.PI; Math.pow
d81e700 verified
raw
history blame
558 Bytes
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Math.html
variety of mathematical operations, such as
trigonometric functions,
the square root and
mathematical constants.
The Math library is also part of the basic Java package, so there is no need to import it separately.
The example method calculates the area of a sphere by retrieving the pi from the Math class and the method pow, which can be used to calculate exponents:
public static double ballArea(double radius) {
return 4 * Math.PI * Math.pow(radius, 2);
}