Java Math sqrt() Method
Example
Return the square root of different numbers:
System.out.println(Math.sqrt(0));
System.out.println(Math.sqrt(1));
System.out.println(Math.sqrt(9));
System.out.println(Math.sqrt(0.64));
System.out.println(Math.sqrt(-9));
Definition and Usage
The sqrt()
method returns the square root of a number.
Syntax
public static double sqrt(double number)
Parameter Values
Parameter | Description |
---|---|
number | Required. A number to find the square root of. |
Technical Details
Returns: | A double value representing the square root of a number.
If the number is less than 0, it returns NaN. |
---|---|
Java version: | Any |
❮ Math Methods