Java pow () method
pow () method returns the first argument to the power of the second argument.
grammar
double pow(double base, double exponent)
parameter
base - any native data types.
exponent - any native data types.
return value
Returns the first argument to the power of the second argument.
Examples
public class Test{ public static void main(String args[]){ double x = 11.635; double y = 2.76; System.out.printf("e 的值为 %.4f%n", Math.E); System.out.printf("pow(%.3f, %.3f) 为 %.3f%n", x, y, Math.pow(x, y)); } }
Compile the above program, the output is:
e 的值为 2.7183 pow(11.635, 2.760) 为 874.008