Java Math hypot()

The syntax of the hypot() method is:

Math.hypot(double x, double y)

Note: The hypot() method is a static method. Hence, we can call the method directly using the class name Math.


hypot() Parameters

  • x, y - double type arguments

hypot() Return Values

  • returns Math.sqrt(x2 + y2)

The returned value should be within the range of the double data type.

Note: The Math.sqrt() method returns the square root of specified arguments. To learn more, visit Java Math.sqrt().


Example 1: Java Math.hypot()


Example 2: Pythagoras Theorem Using Math.hypot()

In the above example, we have used the Math.hypot() method and the Pythagoras Theorem to calculate the hypotenuse of a triangle.