该库类似于其它语言的Math库一样,封装了很多的数学函数,下面来看几个例子就知道了,毕竟简单。
public class test3 {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("9的开平方为:"+Math.sqrt(9));
System.out.println("60读的正玄:"+Math.sin(Math.PI/3));
System.out.println("60读的正玄:"+Math.sin(Math.PI/3));
int a=5,b=4;
System.out.println("a和b的最小值为:"+Math.min(a, b));
System.out.println("a和b的最大值为:"+Math.max(a, b));
// 比较数字大小 如果指定的数与参数相等返回0。如果指定的数小于参数返回 1。如果指定的数大于参数返回 -1。
Integer c=2;
System.out.println("两者比较结果为:"+c.compareTo(a));
}
}
执行如下:
9的开平方为:3.0
60读的正玄:0.8660254037844386
60读的正玄:0.8660254037844386
a和b的最小值为:4
a和b的最大值为:5
两者比较结果为:-1
其它也还有很多的函数,如图所示: