This example shows you how to get the power of n of a number in java using Math class.

The static method Math.pow(double a, double b) can be use to raised the value specified in the a to the power of the value specified in b.

Below is the example code which calculating the power of n of a number in java using Math class.

package com.java.connect.math; //Math power of n of a number in java public class MathPowerExample { public static void main(String[] args) { double number = 10; // Get the power of 3 of number 10. double power = Math.pow(number, 3); System.out.println(number + " power of 3 is : " + power); } }

Below is the out of above example code:

10.0 power of 3 is : 1000.0