1 回答

繁星點點滴滴
TA貢獻(xiàn)1803條經(jīng)驗 獲得超3個贊
java中有一個Math類里面很多靜態(tài)的方法,都是一些常見的數(shù)學(xué)公式的實現(xiàn),例如求平方根的Math.sqrt(n),求a的b次方Math.pow(a, b),求絕對值Math.abs(n)等很多。下面是一些演示。
1 2 3 4 5 6 7 8 9 10 11 | public class MathTest { public static void main(String[] args) { int n = 16; System.out.println(Math.sqrt(n)); System.out.println(Math.pow(2, 3)); System.out.println(Math.abs(-4)); System.out.println(Math.log10(100)); } } |
添加回答
舉報
0/150
提交
取消