Math
public static void main(String[] args) {
//将值向上取整数
double value = Math.ceil(12.1);
System.out.println(value);
//将值向下取整
double value2 = Math.floor(12.9);
System.out.println(value2);
//四舍五入
double value3 = Math.round(12.3);
System.out.println(value3);
double value4 = Math.pow(4, 3);
System.out.println(value4);
//随机数,Random类
Random r = new Random();
int result1 = r.nextInt(); //返回一个随机整数
double result2 = r.nextDouble(); //返回一个随机的小数
System.out.println(result1);
System.out.println(result2);
/**
* 在java只生成的随机数称为伪随机数。
* 生成随机数的时候,要求我们必须传递一个种子进去。种子是一样的 每次生成的随机数都一样
* new Random 默认加了种子,以当前系统时间作为种子
*/
Random r2 = new Random();
int res = r2.nextInt();
int res3 = r2.nextInt();
System.out.println(res);
System.out.println(res3);
Random r3 = new Random();
int res2 = r3.nextInt();
int res4 = r3.nextInt();
System.out.println(res2);
System.out.println(res4);
//生成一个四位数以内的随机数
int res5 = r3.nextInt(9999);
System.out.println(res5);
//随机数第二种用法 默认产生的随机数0-1(不包含1)
double res6 = Math.random();
System.out.println(res6);
//产生一个10-20的随机数
double res7 = res6*10+10;
System.out.println(res7);
}