public class Test { public static void main(String[] args) { System.out.println("圆的面积:" + area(2)); System.out.println("三角形的面积:" + area(3,4,5)); System.out.println("矩形的面积:" + area(3,4)); } //求圆的面积 public static double area(double radius){ return Math.PI * radius * radius; } //求三角形的面积 public static double area(double a, double b, double c){ double s = (a + b + c) / 2; return Math.sqrt(s*(s-a)*(s-b)*(s-c)); } //求矩形的面积 public static double area(double width, double height){ return width * height; } //求椭圆的面积/* public static double area(double a, double b){ return Math.PI * a * b; }*/}求椭圆面积需要2个参数,求矩形面积也需要2个参数,这些参数的数据类型、顺序和数量完全一致,无法实现重载,除非改名。