Find power using Math.pow in Java
Description
The following code shows how to find power using Math.pow.
Example
//ww w. ja v a2 s. co m
public class Main {
public static void main(String[] args) {
// returns 2 raised to 2, i.e. 4
System.out.println(Math.pow(2, 2));
// returns -3 raised to 2, i.e. 9
System.out.println(Math.pow(-3, 2));
}
}
The code above generates the following result.