System.out.println(Math.PI); //圆周率
System.out.println(Math.abs(-10)); //取绝对值
System.out.println(Math.ceil(12.3)); //向上取整,返回double
System.out.println(Math.floor(12.9)); //向下取整,返回double
System.out.println(Math.min(10, 52)); //获取最小值
System.out.println(Math.pow(12, 2)); //12的2次方
System.out.println(Math.random()); //生成0.0-1.0之间的随机小数,包括0.0,不包括1.0
System.out.println(Math.round(12.6)); //四舍五入,
System.out.println(Math.sqrt(4)); //开根号
Math类的方法
最新推荐文章于 2020-08-24 00:08:43 发布