How to express the power of java: First check the API of Math mathematical function; then define an a variable of 5 and a b variable of 3; then use [double c=Math.pow( a, b)】The code finds a raised to the power b; finally run the project.
[Related recommendations: Programming Video Course]
How to express the power of java:
The first step is to check the API of Math mathematical function, you can seepow()
The method returns the power of the second parameter of the first parameter in the format of Math.pow(m,n), which represents the nth power of m, as shown in the following figure:
The second step, we can look at it through an example, define an a variable with a value of 5 and a b variable with a value of 3, use double c=Math.pow(a, b)
The code finds a raised to the power b, as shown in the figure below:
# Step 3: Run the project. You can see on the console that the result of a raised to the power b is 125. , as shown in the figure below:
The fourth step, we can also use a for loop to express the nth power of a number, the code is as shown in the figure below:
The fifth step is to run the project. You can see the same result in the console, as shown in the figure below:
Step 6. Finally, we can learn Math mathematical functions. We can find sine, cosine, tangent, inverse tangent values, etc., as shown in the figure below:
##Related Recommended:
The above is the detailed content of How to express power of java. For more information, please follow other related articles on the PHP Chinese website!