Java 常用类 -Math

package com.xuyigang1234.chp05.sec01;

public class TestMath {
    public static void main(String[] args) {
        System.out.println("最大值:"+Math.max(1, 2));
        System.out.println("最小值:"+Math.min(1, 2));
        System.out.println("四舍五入:"+Math.round(4.5));
        System.out.println("3的4次方:"+Math.pow(3, 4));
        System.out.println("4的平方根: "+Math.sqrt(4));
    }

}
输出:
最大值:2
最小值:1
四舍五入:5
3的4次方:81.0
4的平方根: 2.0
原文地址:https://www.cnblogs.com/xyg-zyx/p/10005613.html