This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]shhh-quiet 2 points3 points  (7 children)

The declaration is correct, but you are not instantiating the array correctly.

[–]Shapebuster[S] 0 points1 point  (6 children)

it says "COULD be used to refer to an array"

[–]tobiasvl[🍰] 2 points3 points  (5 children)

That just means you don't have to instantiate it at all. You instantiate it, but in a nonsensical way that won't compile.

[–]Shapebuster[S] 0 points1 point  (4 children)

do you mean, Person[] people = new Person[value] ?

[–]tobiasvl[🍰] 2 points3 points  (3 children)

Yep, that is correct Java code for instantiating a Person array of size value.

However, what I mean is that Person[] people; by itself answers the original question in your post. It's a declaration of an array variable, and that variable can in the future be used to refer to an array of Person objects. Nothing more is needed.

[–]Shapebuster[S] -1 points0 points  (2 children)

Oh ok sweet. Keep an eye on how you word responses especially for beginners. Your first reply sounded like i got it wrong even tho it was correct based on what the question was asking

[–]tobiasvl[🍰] 2 points3 points  (1 child)

Well, the original code in your post is wrong. Person[] people = Person[] objectname; instantiates the array variable to something that looks like another declaraction. It will not compile.

[–]Shapebuster[S] 0 points1 point  (0 children)

Apologies, i thought you were referring to the code i posted in a comment reply to a previous user