KaiquanMah commited on
Commit
d81e700
·
verified ·
1 Parent(s): 8e13e28

Math.PI; Math.pow

Browse files
Week 3: Objects, files and exceptions/15a Math-library ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Math.html
2
+ variety of mathematical operations, such as
3
+ trigonometric functions,
4
+ the square root and
5
+ mathematical constants.
6
+ The Math library is also part of the basic Java package, so there is no need to import it separately.
7
+
8
+ 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:
9
+
10
+
11
+
12
+ public static double ballArea(double radius) {
13
+ return 4 * Math.PI * Math.pow(radius, 2);
14
+ }
15
+
16
+
17
+
18
+