Math
package Baozhuang; public class MathTest { public static void main(String[] args) { int m = 4; int n = 2; int max = Math.max(m, n); System.out.println(max);//最大值 int min = Math.min(m, n); System.out.println(min);//最小值 double pow = Math.pow(m, n); System.out.println(pow);//m的n次方 double sqrt = Math.sqrt(m); System.out.println(sqrt);//对m开平方 //random 随机生成从0到10的随机数,包括0 int random = (int) (Math.random()*10+1); System.out.println("生成随机数"+random); //生成0或1的随机数 int random1 = Math.random()*2 >= 0.5?1:0; System.out.println(random1); //生成5到10的随机数 int random2 = (int)(Math.random()*6+5); System.out.println("5到10随机数"+random2); //abs 求绝对值 int i = -6; int abs = Math.abs(i); System.out.println(abs); double angle = (Math.PI)/2; double sin = Math.sin(angle);//正旋 System.out.println(sin); double cos = Math.cos(angle);//余旋 System.out.println(cos); double tan = Math.tan(angle); System.out.println(tan);//正切 double asin = Math.asin(angle); System.out.println(asin); double acos = Math.acos(asin); System.out.println(acos); } }