我有一個對象數組,其中一些使用包含基類中不可用函數的擴展版本。當數組由基類定義時,如何通過數組調用該函數?Java - 通過對象數組在擴展類中調用函數
例
Shape[] shapes = new Shape[10];
shapes[0] = new Circle(10) //10 == radius, only exists in circle class which extends Shape
shapes[0].getRadius(); //Gives me a compilation error as getRadius() doesn't exist in the
Shape class, only in the extended Circle class. Is there a way around this?