Recently trying to code a little little program I came up with an error that made me feel like a stupid. What bothers me is that I don{t know why the Java compiler acts like this so I?ll show you what happened and I expect a trusthworthy and complete answer from you folks:
The syntax you are using is only for initialization of an array and for assignment. It means you can comma separated values to initialize the array elements only at the time when you declare the array. Since your declaration and assignment have been separated in two statements you are getiing array. You can always do this: int[] myArray = {1,2,3,4,5};
You cannot do this: int[] myArray ; myArray = {1,2,3,4,5};