What's the difference between two array declarations in Java? -


In my book they are changing the way the array is declared between the following two ways:

 < Code> int array1 [] = {1, 2, 3}; Int [] array2 = {1, 2, 3};   

I was wondering what was the difference between what was the position of both the brackets, and why is it that when I put brackets after the name (like in array 1), So why should I either start it for values ​​or a new array, but in array2, I just say "int [] array2;" I can say it and then use it later ...

They are similar except that That you mention that you have to start this if you put brackets after the name, a benefit of declaring them before the name starts in a variety of ways:

  int [ ] MyArray1, myArray2; Int myArray1 [], myArray2 [];   

In the manner of Java to keep the parenthesis before the name of the array.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -