# 086 TestOverloading.java package ch06; /* * 此範例為方法多載的示範說明 */ public class TestOverloading { // 圓形面積 public static double areaMeasure(double radius) { return radius * radius * 3.14; } // 長方形面積 public static double areaMeasure(double height, double width) { return height * width; } // 梯形面積 public static double areaMeasure(double upper, double bottom, double height) { return (upper + bottom) * height / 2; } public static void main(String args[]) { double i = areaMeasure(3.0); double j = areaMeasure(3.0, 4.0); double k = areaMeasure(3.0, 4.0, 5.0); System.out.println("圓形面積=" + i); System.out.println("長方形面積=" + j); System.out.println("梯形面積=" + k); } }
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up