After reading, I came to know that, arrays in Java
are objects. The name of the array is not the actual array, but just a reference. The new operator creates the array on the heap and returns the reference to the newly created array object which is then assigned to array variable (name). Something like the following:
int[] myArray = new int[5];
But I also used these two type of array declaration.
int[] myArray= new int[]{5,7,3};
and
int[] myArray= {5,7,3};
Both of the above are legal and work fine. So what's the difference between these two and when should I use them?