Using pow () – method in Java
•
Java
I am writing a program in Java. The user should enter an integer n. then my program should create an array with entries of [1.25 ^ 0], [1.25 ^ 1], [1.25 ^ n]. To do this, I tried to use the pow () – method The code for creating the array is as follows:
for (int i = 0; i < n; i++) { functionG[i] = pow(1.25,n); }
However, this gave me the error message: "the method pow (double, int) does not recognize the type function" (the function is the name of my class)
Who knows how I can solve this problem? I'm pretty sure I'm on the right track. I just need to make the method work properly
Any help will be appreciated!
Solution
Using math Pow (double, double), or statically import POW as follows:
import static java.lang.Math.pow;
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码