Math
Math类可以直接使用不用导包
Math类被final修饰,不能被继承,构造器私有化,不能创建Math类对象
Math.random //随机值
Math.abs//绝对值
Math.ceil//向上取值
Math.floor//向下取值
Math.round//四舍五入
Math.max//最大值
Math.min//最小值
Random
Math.random()返回大于等于0.0并且小于1的double值,
1
Random random=new Random(System.currentTimeMillis());
int i= random.nextInt();
2
Random random2=new Random();
int i=random2.nextInt(5); //包括0但是不包括5的int值
double d=random2.nextDouble();//在0和1.0之间的double值