Java Math.hypot(double x, double y)

Syntax

Math.hypot(double x, double y) has the following syntax.

public static double hypot(double x,  double y)

Example

In the following code shows how to use Math.hypot(double x, double y) method.


//from  ww  w  .ja  va 2 s.c o  m
public class Main {

   public static void main(String[] args) {

      double x = 123456.7;
      double y = -123.45;

      // call hypot and print the result
      System.out.println("Math.hypot(" + x + "," + y + ")=" + Math.hypot(x, 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