Java Math.sqrt() method

The java.lang.Math.sqrt() is used to return the square root of a number.

Syntax

Parameter

Return

  • If the argument is positive double value, this method will return the square root of a given value.
  • If the argument is NaN or less than zero, this method will return NaN.
  • If the argument is positive infinity, this method will return positive Infinity.
  • If the argument is positive or negative Zero, this method will return the result as Zero with same sign.

Example 1

Test it Now

Output:

9.0

Example 2

Test it Now

Output:

NaN

Example 3

Test it Now

Output:

NaN

Example 4

Test it Now

Output:

Infinity

Example 5

Test it Now

Output:

0.0

Next TopicJava Math




Latest Courses