Math.sqrt(double n),计算平方根
System.out.println(Math.sqrt(4));//输出:2.0
Math.cbrt(double n),计算立方根
System.out.println(Math.cbrt(8));//输出:2.0
Math.pow(double a,double b),计算a的b次方
System.out.println(Math.pow(2, 3));//输出:8.0
Math.max(Number a,Number b),返回a,b中的最大值
System.out.println(Math.max(1, 3));//输出:3
Math.min(Number a,Number b),返回a,b中的最小值
System.out.println(Math.min(4, 2));//输出:2
Math.abs(Number n),返回绝对值
System.out.println(Math.abs(-20));//输出:20
Math.ceil(double n),返回大的值,向上取整
System.out.println(Math.ceil(2.3));//输出:3.0
System.out.println(Math.ceil(-2.3));//输出:-2.0
Math.floor(double n),返回最小的值,向下取整
System.out.println(Math.floor(2.3));//输出:2.0
System.out.println(Math.floor(-2.3));//输出:-3.0
Math.random()返回一个double类型 >=0.0,<1.0 的随机数
System.out.println(Math.random());//返回数double n, 0.0<=n<1.0
System.out.println(Math.random()*100);//返回数double n, 0.0<=n<100.0
Math.rint(double n),四舍五入,返回double类型,.5时取偶数
System.out.println(Math.rint(3.5));//输出:4.0 .5时取偶数
System.out.println(Math.rint(4.5));//输出:4.0 .5时取偶数
System.out.println(Math.rint(4.51));//输出:5.0
Math.round(n),四舍五入,n为float返回int类型,n为double返回long类型
System.out.println(Math.round(2.5f));//输出:3
System.out.println(Math.round(4.5));//输出:5
Math.PI,圆周率的值