开发者

Array declaration in Java [duplicate]

开发者 https://www.devze.com 2023-02-14 12:24 出处:网络
This question already has answers here: 开发者_如何学运维 Closed 10 years ago. Possible Duplicate:
This question already has answers here: 开发者_如何学运维 Closed 10 years ago.

Possible Duplicate:

Difference between int[] array and int array[]

Is int[] arr; functionally the same as int arr[];?


Yes. You can put the braces in either place when declaring an array.

Bonus: you can even put 'em here: int []arr


Yes, the functionality is the same. You can have the braces anywhere.

int[] a,b,c[];

is equivalent to

int a[],b[],c[][];


It's just the matter of style. You can pick the style you like. They perform exactly the same. Some claim that if you write "int[] array", it will be clearer that it's an array of integer rather than writing "int array[]".


It is, it's just to appease C++ developers they include int arr[]. (Or at least what I told in school)


Yes it's the same. int[] arr is more convenient though.

0

精彩评论

暂无评论...
验证码 换一张
取 消