How to Use Math.sqrt(x) in Java


In this example we will show you how to use math.sqrt(x) to return the square root of x in Java.

Source Code

package com.beginner.examples;

public class Sqrt {
  public static void main(String[] args) {
    System.out.println(Math.sqrt(16)); // return the square root
  }
}

Output:

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