system.out.println(math.pi);
system.out.println(math.abs(-10)); //取絕對值
system.out.println(math.ceil(12.3));//向上取整
system.out.println(math.ceil(12.99));
system.out.println(math.floor(12.99));//向下取整
system.out.println(math.floor(12.3));
//獲取兩個值中的最大值
system.out.println(math.max(20, 30));
//求前面的數是底數 後面的數是指數 2的3次方
system.out.println(math.pow(2, 3));
//生成0.0到1.0之間的小數包括0.0不包括1.0
system.out.println(math.random());
//四捨五入
system.out.println(math.round(12.3f));
system.out.println(math.round(12.9f));
//開平方 根號2 根號4
system.out.println(math.sqrt(4));
system.out.println(math.sqrt(2));
math類中一些基本方法
package com.niuke.test public class mathdemo math.pi 記錄的圓周率 math.e 記錄e的常量 math中還有一些類似的常量,都是一些工程數學常用量。math.abs 求絕對值 math.sin 正弦函式 math.asin 反正弦函式 math....
Java中Math類的一些主要方法
math.pi pi pi 3.14 math.e e int abs int i 求絕對值 int max int i1,int i2 求兩個之中的最大數 double floor double b 求不大於d的整數,返回的結果是double型別的 long round double d 求靠近d...
Math的一些重要的API
math的構造方法是私有的 math.max 15,18 返回兩者中的較大的 math.min 15,18 返回兩者中的較小的 math.random 隨機返回乙個 0.0到1.0中間的double型別的小數 math.abs 15 返回絕對值的 math.acos 0.7 這是反余弦值,輸入型別必...