//取绝对值
System.out.println(Math.abs(-6.6));
//向上取整
System.out.println(Math.ceil(12.1));
//向下取整
System.out.println(Math.floor(12.9));
//取两数最大值
System.out.println(Math.max(12.1,12.9));
//取两数最小值
System.out.println(Math.min(12.1, 12.9));
//次幂
System.out.println(Math.pow(2, 10));
//随机小数
System.out.println(Math.random());
//四舍五入
System.out.println(Math.round(12.49999999999999999));
总结:这是取各种值的方式
原文:https://www.cnblogs.com/kun123/p/12096671.html