java.lang.Math
Static class — no instances allowed
public static final double PI = 3.14159265...;
public static final double E = 2.71828182...;
public static double sqrt(double a) // → double
public static double pow(double a, double b) // → double
public static double floor(double a) // → double
public static double ceil(double a) // → double
public static long round(double a) // → long
public static double abs(double a) // → double
public static double max(double a, double b) // → double
public static double min(double a, double b) // → double
✕ Cannot do this
Math m = new Math();The constructor is
private, so the compiler won't let you.
Live Examples
Math.PI
3.141592653589793
Math.sqrt(25)
5.0
Math.pow(5, 2)
25.0
Math.floor(12.8)
12.0
Math.ceil(12.2)
13.0
Math.round(12.5)
13
Math.abs(-7.3)
7.3
Math.max(10, 25)
25.0
Try it: Area of a circle =
Math.PI * Math.pow(r, 2)
radius =
→ area =