# How to get square root of number in java

In this tutorial. we will see if how to get Square Root of number in java.
It is very simple to get square root of number in java. You can simply use Math’s sqrt() method to calculate square root of number.

## Syntax

`double sqrt(double d)`

### Return type

It returns square root of the number.

## Square root of number

Let’s see sqrt method with the help of example.

```import java.math.*;
package org.arpit.java2blog;

public class SquareRootMain {

public static void main(String[] args) {
double d1=26.0;
System.out.println("Square root of 26:"+Math.sqrt(d1));

double d2=56.0;
System.out.println("Square root of 56:"+Math.sqrt(d2));

double d3=83.0;
System.out.println("Square root of 83:"+Math.sqrt(d3));
}

}```

Above program will generate below output.

Square root of 26:5.0990195135927845
Square root of 26:7.483314773547883
Square root of 26:9.1104335791443

That’s all about square root of number in java

The post How to get square root of number in java appeared first on Java2Blog.

This post first appeared on How To Learn Java Programming, please read the originial post: here

# Share the post

How to get square root of number in java

×