Write a method that raises a number to a power without using Math.pow() method
public class Power {
public static void main(String[] args) {
int base = 3, exponent = 4;
long result = 1;
while (exponent != 0)
{
result *= base;
--exponent;
}
System.out.println("Answer = " + result);
}
}
Also in Java:
- using class in java
- java.sql.SQLException: Before start of result set
- has been compiled by a more recent version of the Java Runtime (class file version 56.0), this version of the Java Runtime only recognizes class file versions up to 55.0
- Java use Base64
- counting the sequence of character in string java
- vector in java
- How to draw Bezier Curve in Android
- Please ensure that your JAVA_HOME points to a valid Java SDK. You are currently pointing to: /usr/lib/jvm/java-13-oracle
- arraylist to array java
- java iterate through map
- JOptionPane with drop down list java
- isnumber java
- java fullscreen jframe
- generate random number java
- install java debian 8
- java constructor genertic
- iterate over map keys java
- clear stringbuilder java
- android hide and show bottom navigation
- check if value exists in hashset java
- deleting elements of an array in java
- java output length of each line in a text document
- java script to detect the crome browser
- 2d arrays | java