The java.lang.Math.sqrt() returns the square root of a value of type double passed to it as argument. If the argument is NaN or negative, then the result is NaN. If the argument is positive infinity, then the result is positive infinity. If the argument passed is positive zero or negative zero then the result will be same as that of the argument.
public static double sqrt(double a) Parameter : a : the value whose square root is to be returned. Return : This method returns the positive square root value of the argument passed to it.
Example 1: To show working of java.lang.Math.sqrt() method.
5.477225575051661 6.708203932499369 7.745966692414834 9.486832980505138
Example 2: To show working of java.lang.Math.sqrt() method when argument is NaN or +infinity.
NaN Infinity NaN
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.