public class Demo02 {
public static void main(String[] args) {
//abs取绝对值
System.out.println(Math.abs(-88));
//ceil向上取整
System.out.println(Math.ceil(3.99));
//floor向下取整
System.out.println(Math.floor(3.01));
//round四舍五入
System.out.println(Math.round(3.14));
//取二个数最大值
System.out.println(Math.max(55, 66));
//2的3次方
System.out.println(Math.pow(2, 3));
}
}
88
4.0
3.0
3
66
8.0
该代码示例展示了Java中Math类的一些基本方法,如计算绝对值、向上取整、向下取整、四舍五入以及求最大值和幂运算。
1118

被折叠的 条评论
为什么被折叠?



