天天看点

Java常用类库(Math类)

package org.math;

public class MathDemo01 {

public static void main(String[] args) {

System.out.println("求平方根:"+Math.sqrt(9.0));

System.out.println("求两个数的最大值:"+Math.max(10, 30));

System.out.println("求两个数的最小值:"+Math.min(10, 30));

System.out.println("2的3次方:"+Math.pow(2, 3));

System.out.println("四舍五入:"+Math.round(33.6));

}

}