# Power of Number Java Math pow() Function

java.lang.Math class comes with many methods to do simple basic numeric operations. One such one is pow() method which returns power of a number raised to another number.

One advantage of Math class methods is that they are declared as static so that they can be called without the need of object creation.

Following is the Math class signature as defined in java.lang package.

public final class Math extends Object

Following is the signature of pow() method as defined in Math class.

• double pow(double a, double b): Returns a double value of the first argument raised to the power of the second argument.

Notice, the method takes two double values and returns a double value.

The first argument, a is treated as the base and the second number, b is treated as exponential value; a raised to b.

###### Example on Power of Number Java Math pow() Function using of the above method.
```public class MathFunctionDemo
{
public static void main(String args[])
{
System.out.println("\npow(2,3) is " + Math.pow(2, 3));
System.out.println("pow(-2,-3) is " + Math.pow(-2, -3));
System.out.println("pow(2.4,3.8) is " + Math.pow(2.4, 3.8));
System.out.println("pow(-2.4,-3.8) is " + Math.pow(-2.4, -3.8));
System.out.println("pow(2.0,0) is " + Math.pow(2.0, 0));
System.out.println("pow(2.0,1) is " + Math.pow(2.0, 1));
}
}

```

Output screenshot of Power of Number Java Math pow() Function

### 4 thoughts on “Power of Number Java Math pow() Function”

1. SIR,
i am doing Hospital Management system project.
HOW to Generate UHID(universal Health ID) automatically by Java/J2ee and mysql.

UHID is used for uniqueness Patient ID.