How to Get Square Root of a Number in Java


In this example, let us see how to find square root of a given number with sqrt method of Math class in Java.

Source Code

package com.beginner.examples;

public class SquareRootExample {

    public static void main(String[] args){
    	//return square root of a number.
    	System.out.println(Math.sqrt(16));
        System.out.println(Math.sqrt(6.3));
    }
}

Output:

4.0
2.5099800796022267
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments