java tutorial - Java Math.sqrt() Method - java programming - learn java- java basics - java for beginners

Learn Java - Java tutorial - Java numbers sqrt - Java examples - Java programs
Description
The Math.sqrt() method returns the square root of the argument.
Syntax
double sqrt(double d)
click below button to copy the code. By - java tutorial - team
Options
Detailed information about the parameters:
- base - any primitive data type.
- exponent - any primitive data type.
- In Java, Math.sqrt() returns the square root of the argument.
Sample Code
public class Test {
public static void main(String args[]) {
double x1 = 16;
double x2 = 2.25;
double x3 = 0.25;
double x4 = 88.675;
System.out.printf("sqrt(%.3f) = %.3f%n", x1, Math.sqrt(x1));
System.out.printf("sqrt(%.3f) = %.3f%n", x2, Math.sqrt(x2));
System.out.printf("sqrt(%.3f) = %.3f%n", x3, Math.sqrt(x3));
System.out.printf("sqrt(%.3f) = %.3f%n", x4, Math.sqrt(x4));
}
}
click below button to copy the code. By - java tutorial - team
Output
sqrt(16,000) = 4,000
sqrt(2,250) = 1,500
sqrt(0,250) = 0,500
sqrt(88,675) = 9,417