Java Math.sqrt(double a)

Syntax

Math.sqrt(double a) has the following syntax.

public static double sqrt(double a)

Example

In the following code shows how to use Math.sqrt(double a) method.


/*from  w w w.  j a v a  2 s .  c o  m*/


public class Main {

   public static void main(String[] args) {

      double x = 9;
      double y = 25;

      // print the square root of these doubles
      System.out.println("Math.sqrt(" + x + ")=" + Math.sqrt(x));
      System.out.println("Math.sqrt(" + y + ")=" + Math.sqrt(y));

   }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable