我有一个对象数组,其中一些使用扩展版本,其中包含基类中不可用的函数。当数组由基类定义时,如何通过数组调用该函数?
例子
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?