java.io package is used for input and output operations in Java.
Math.pow() method is used in Java and it is present in the java.lang package. This method is used to calculate the power of a number.
Example 1: In this example, we calculate the power of numbers 2 and 3.
Code: double powerOfTwo = Math.pow(2, 3); System.out.println("2 raised to the power of 3 is: " + powerOfTwo);
Output: 2 raised to the power of 3 is: 8.0
Example 2: In this example, we calculate the power of a number and store the result in a variable using Math.pow() method.
Code: double num = 4; double power = 3; double result = Math.pow(num, power); System.out.println(num + " raised to the power of " + power + " is: " + result);
Output: 4.0 raised to the power of 3.0 is: 64.0
We don't need to import any specific package or library to use Math.pow() method as it is present in the java.lang package which is imported by default in Java programs.
Java Math.pow - 30 examples found. These are the top rated real world Java examples of java.io.Math.pow extracted from open source projects. You can rate examples to help us improve the quality of examples.