- abs 绝对值
- pow 求幂
- ceil 向上取整
- floor 向下取整
- round 四舍五入
- sqrt 开平方
- random 求随机数,返回[0-1)之间的随机数
- max 求两个数的最大值
- min 求两个数的最小值
练习
public static void main(String[] args) {
// 求2到9之间的随机数
for (int i = 0; i < 100; i++) {
System.out.println((int) (Math.random() * (9 - 2 + 1) + 2));
}
}