該方法返回第一個參數(shù)的值增加到第二個參數(shù)的冪。
double pow(double base, double exponent)
此方法返回第一個參數(shù)的值增加到第二個參數(shù)的冪。
下面是一個使用這個方法的例子 -
class Example { static void main(String[] args) { double x = 11.635; double y = 2.76; System.out.printf("The value of e is %.4f%n", Math.E); System.out.printf("pow(%.3f, %.3f) is %.3f%n", x, y, Math.pow(x, y)); } }
當我們運行上面的程序,我們將得到以下結果 -
The value of e is 2.7183 pow(11.635, 2.760) is 874.008
更多建議: