Java Math.pow(double a, double b)

Syntax

Math.pow(double a, double b) has the following syntax.

public static double pow(double a,  double b)

Example

In the following code shows how to use Math.pow(double a, double b) method.


//  w  w w  .j  av  a  2s. c o m
public class Main {

   public static void main(String[] args) {
      double x = 1.2;
      double y = 5.4;

      // print x raised by y and then y raised by x
      System.out.println("Math.pow(" + x + "," + y + ")=" + Math.pow(x, y));
      System.out.println("Math.pow(" + y + "," + x + ")=" + Math.pow(y, x));

   }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable