Raising a number to a power in Java

Use the static method pow in the Math class.

public class Main
{
   public static void main(String[] args) {
      System.out.println(Math.pow(2.0, 2.0));    // 4.0
      System.out.println(Math.pow(1, 0));        // 1.0
      System.out.println(Math.pow(-2, 2.0));     // 4.0
      System.out.println(Math.pow(2.0, 2.5));    // 5.65685424949238
      System.out.println(Math.pow(2.0, -2.5));   // 0.17677669529663687
      System.out.println(Math.pow(-2.0, -2.5));  // NaN
      System.out.println(Math.pow(0, 0));        // 1.0
      System.out.println(Math.pow(0, -1));       // Infinity
   }
}