Java pow() method


Java Number类Java Number Class


The pow() method is used to return the first parameter raised to the power of the second parameter.

grammar

double pow(double base, double exponent)

parameter

  • base -- Any native data type.

  • exponent -- Any native data type.

return value

Return the first parameter raised to the power of the second parameter.

Example

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 and the output result is:

e 的值为 2.7183
pow(11.635, 2.760)  874.008

Java Number类Java Number Class