Posts Tagged Math

Java – Math pow() Example, Math pow() Program

Sunday, November 15th, 2009

Math class is part of java.lang package. Math pow method returns value of first argument of power of second numbers e.g 23. pow function return type is double.

Math pow example explains how to use Math pow function in java.

public class JavaMathPowExample {

    public static void main(String[] args) {

        double E1 = Math.pow(2, 3); // 2x2x2=8

        double E2 = Math.pow(2.23, 3.45);

        System.out.println("Math pow value :"+E1);
        System.out.println("Math pow value :"+E2);
    }
}

Output

Math pow value :8.0
Math pow value :15.909325868265608