Java Data Type Tutorial - 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 .  j a v a 2  s  .c  om*/
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.