所以我敢肯定這是一個簡單的問題來回答,我是新來的java,但我想傳遞一個數組到一個參數,我有問題。下面我創建3種形狀,我想myShapes或數組傳遞到AreaCalculator在構造函數中使用java中的函數
,但我得到的錯誤 -
cannot find symbol
symbol : method AreaCalculator()
location: class Points
AreaCalculator();
public static void main(String[] args)
{
Shape[] myShapes = new Shape[3];
AreaCalculator(myShapes);
}
class AreaCalculator{
public AreaCalculator(Shape[] shapes){
}
}
使用'new'調用構造函數。 https://docs.oracle.com/javase/tutorial/java/javaOO/constructors.html –