Difference between int[] array and int array[]

前端 未结 25 2976
轻奢々
轻奢々 2020-11-21 07:18

I have recently been thinking about the difference between the two ways of defining an array:

  1. int[] array
  2. int array[]
  3. <
25条回答
  •  天涯浪人
    2020-11-21 08:09

    Yep, exactly the same. Personally, I prefer

    int[] integers; 
    

    because it makes it immediately obvious to anyone reading your code that integers is an array of int's, as opposed to

    int integers[];
    

    which doesn't make it all that obvious, particularly if you have multiple declarations in one line. But again, they are equivalent, so it comes down to personal preference.

    Check out this page on arrays in Java for more in depth examples.

提交回复
热议问题