java.lang.Math class comes with many methods to do simple basic numeric operations. One such one is pow() method which returns power of a number raised to another number.
One advantage of Math class methods is that they are declared as static so that they can be called without the need of object creation.
Following is the Math class signature as defined in java.lang package.
public final class Math extends Object
Following is the signature of pow() method as defined in Math class.
- double pow(double a, double b): Returns a double value of the first argument raised to the power of the second argument.
Notice, the method takes two double values and returns a double value.
The first argument, a is treated as the base and the second number, b is treated as exponential value; a raised to b.
Example on Power of Number Java Math pow() Function using of the above method.
public class MathFunctionDemo
{
public static void main(String args[])
{
System.out.println("\npow(2,3) is " + Math.pow(2, 3));
System.out.println("pow(-2,-3) is " + Math.pow(-2, -3));
System.out.println("pow(2.4,3.8) is " + Math.pow(2.4, 3.8));
System.out.println("pow(-2.4,-3.8) is " + Math.pow(-2.4, -3.8));
System.out.println("pow(2.0,0) is " + Math.pow(2.0, 0));
System.out.println("pow(2.0,1) is " + Math.pow(2.0, 1));
}
}
Output screenshot of Power of Number Java Math pow() Function
What is the difference b/w psvm(String arg[]) and psvm(String… arg) ?
One takes a string array object as parameter and one string object. First one is callback method and the second one you must call.
SIR,
i am doing Hospital Management system project.
HOW to Generate UHID(universal Health ID) automatically by Java/J2ee and mysql.
UHID is used for uniqueness Patient ID.
plz reply with Answer immediately
by mail: [email protected]
Thank u
Use a mixture of uppercase, lowercase and digits. Decide the length.