0

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){

}
}
1

1 Answer 1

2

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);
Sign up to request clarification or add additional context in comments.

3 Comments

I don't know why your question was downvoted, but it was probably because you don't seem to have done any research into constructors at all before you posted it. But you'd have to ask the downvoter to find out the real reason.
I know how to use constructors I just think you're right about making a new object.
@user4254704 no, you don't know how to use constructors, since you don't know that they're invoked using new. This is covered by any basic Java learning material, and a simple google search would have allowed you to learn that. That's why you were downvoted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.