In this example, let us see how to find a power with pow method of Math class in Java.
Source Code
package com.beginner.examples;
public class PowerExample {
public static void main(String[] args){
//return power value.
System.out.println(Math.pow(2,2));
System.out.println(Math.pow(-3,3));
System.out.println(Math.pow(2,-1));
}
}
Output:
4.0
-27.0
0.5