public class Main { public static void main(String[] args) { // 1. 创建不同图形对象(多态:父类引用指向子类对象) Shape circle = new Circle(2); Shape rectangle = new Rectangle(3, 4); Shape triangle = new Triangle(5, 4); // 2. 统一打印面积 System.out.println("=== 圆的面积 ==="); ShapeUtil.printArea(circle); System.out.println("=== 矩形的面积 ==="); ShapeUtil.printArea(rectangle); System.out.println("=== 三角形的面积 ==="); ShapeUtil.printArea(triangle); } }