-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMathClassIn.java
More file actions
45 lines (35 loc) · 1.74 KB
/
MathClassIn.java
File metadata and controls
45 lines (35 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
public class MathClassIn {
// math class in java
// contains a lot of method to perform math operations
public static void main(String[] args) {
System.out.println("By Bro Code");
System.out.println("PI : "+Math.PI);
// Math is the class and PI is the constant here which prints
// the value of PI
// System.err.println(); --> what (err) is this ?
System.out.println("Eculids number : "+Math.E);
// Math is the class E is constant in this class
// to print the eculids number
// math class contain static method so you dont need to create objects
// of math class to access the methods of it
// like you do in random class(need to create object in random class
// because methods in it are non static)
// ********* Other important methods(static) in Math class are *************
System.out.println(" methods in random class can take diffrent data type as args ");
// System.out.println("minValue : "+Math.min(34, 55 ));
//
// System.out.println("maxValue : "+Math.max(55, 78));
//
// System.out.println("Power method takes two arguments(base, power) : "+Math.pow(2,3 ));
//
// System.out.println("Absolute value Method : "+Math.abs(-45));
//
// System.out.println("Square root Method : "+Math.sqrt(9));
// System.out.println("Returns Sum of its Arguments thorws exception if result overflow an integer");
// System.out.println(" "+Math.addExact(242343424 , 384272777));
// System.out.println(" "+ Math.addExact(45372384235l , 45372384235l));
// System.out.println("rounds-off the value : "+Math.round(3.64));
// System.out.println("rounds-off the value to upper value : "+Math.ceil(5.33));
// System.out.println("rounds-off the value to lower value : "+Math.floor(4.97));
}
}