In Java, why do you need to put brackets before the name aray?

I was told that

int[] numbers 

and

int numbers[] 

are equivalent. I only ever saw him. What momentum is there, if ever, to write the last?

+3
source share
3 answers

It does not matter, but my personal preference is for int[] numbers, since it follows the pattern more logically class instance_name.

After all you really do is an "array of integers" called "numbers", the second form is a bit misleading, because it declares more of an "integer" called "numbers", and also, essentially, numbers. "

+5
source

. . , C Java . Java malloc .

+7

just because we previously stated in C. two options are available ... are chosen at the discretion of ur. It doesn't matter, java provided a new way to declare an array and remained the same way to declare an array. Complete freedom for the programmer .... cool stuff. no confusion whatsoever.

0
source

Source: https://habr.com/ru/post/1750033/


All Articles