Flash cards
Review the key moves
What is the main idea behind Java Math hypot() Method?
Lesson checks
Practice each idea before moving on
Short Mimo-style checks built from this lesson's code, terms, and sequence.
Which statement best captures the main point of this lesson?
Complete the missing token from the example code.
___.out.println(Math.hypot(3, 4));Put the learning moves in the order that makes the concept easiest to apply.
❮ Math Methods
Example
System.out.println(Math.hypot(3, 4));
System.out.println(Math.hypot(1, 1));
System.out.println(Math.hypot(1, 10));Definition and Usage
The hypot() method returns the length of the hypotenuse of a right angle triangle, which is equivalent to the distance between a 2D point (x, y) and the origin (0, 0).
This method returns a value equal to Math.sqrt(x * x + y * y) but it is optimized to prevent overflows and underflows caused during intermediate operations such as addition and multiplication.
Syntax
public static double hypot(double
x , double
y )Parameter Values
| Parameter | Description |
|---|---|
| x | Required. The x coordinate of a point. |
| y | Required. The y coordinate of a point. |
Technical Details
| Returns: | A double value representing the distance between a point (x, y) and the origin (0, 0). |
|---|---|
| Java version: | 1.5+ |