📄 hypotenuse.java
字号:
// Introduced in Chapter 4/** Compute the hypotenuse of a right triangle. */public class Hypotenuse { /** Return the square of the number x. */ public static double square(double x) { return x * x; } /** * Return the hypotenuse of a right triangle with side lengths x * and y. */ public static double hypotenuse(double x, double y) { double x2 = square(x); double y2 = square(y); return Math.sqrt(x2 + y2); } /** Test the methods. */ public static void main(String[] args) { double result = hypotenuse(3, 4); System.out.println(result); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -