Java Math.pow() methodThe java.lang.Math.pow() is used to return the value of first argument raised to the power of the second argument. The return type of pow() method is double. SyntaxParameterReturnThis method returns the value of ab
Example 1public class PowExample1 { public static void main(String[] args) { double x = 5; double y = 4; //returns 5 power of 4 i.e. 5*5*5*5 System.out.println(Math.pow(x, y)); } } Output: 625.0 Example 2public class PowExample2 { public static void main(String[] args) { double x = 9.0; double y = -3; //return (9) power of -3 System.out.println(Math.pow(x, y)); } } Output: 0.0013717421124828531 Example 3Test it NowOutput: NaN Example 4Test it NowOutput: 3.5461138422596736 Next TopicJava Math |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India