Reputation: 27
So I'm sure this is an easy question to answer and I'm new to java but I want to pass an array into an argument and I'm having issues. Below I create 3 shapes and I'm trying to pass myShapes or that array into AreaCalculator
but I get the error -
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){
}
}
Upvotes: 0
Views: 44
Reputation: 79877
If you're trying to make a new AreaCalculator
object, you should write
new AreaCalculator(myShapes);
and you probably want to assign the result to a variable, so you can do more things to it later.
AreaCalculator myCalculator = new AreaCalculator(myShapes);
Upvotes: 2