How to find a power (compute exponential values) using Math.pow() method in Java

1 Answer

0 votes
package javaapplication1;

public class JavaApplication1 {

    public static void main(String[] args) {

        System.out.println(Math.pow(2, 2));
        System.out.println(Math.pow(2, 3));
        
        System.out.println(Math.pow(3, 2));
        System.out.println(Math.pow(-3, 2));
        System.out.println(Math.pow(3, -2));
        System.out.println(Math.pow(-3, -2));
    }
}
   
/*
      
run:

4.0
8.0
9.0
9.0
0.1111111111111111
0.1111111111111111
  
*/

 



answered Nov 8, 2016 by avibootz
...