Square root. Consider this program—it does not import java.lang.Math at its top. Instead we directly access Math.sqrt using its composite name. We already know what sqrt does.
Syntax:-
Math.sqrt(variable)
Here variable is double datatype
sqrt method is used for finding square root of a number.
Math.sqrt(9) = 3
Java program that uses Math.sqrt
public class Program {
public static void main(String[] args) {
// ... Test the sqrt method.
double value = java.lang.Math.sqrt(4);
double value2 = java.lang.Math.sqrt(9);
System.out.println(value);
System.out.println(value2);
}
}
Output
2.0
3.0
6. square root of the number using java Math ClassSyntax:-
Math.sqrt(variable)
Here variable is double datatype
sqrt method is used for finding square root of a number.
Math.sqrt(9) = 3
No Comment to " Square Root Using Java Program "