Java allows you to initialize an array using keys in the following way:
int [] array = new int[] {1,2,3};
Said format, only in case we are declaring the variable , it can be simplified to
int [] array = {1,2,3};
On the other hand, the first form does work without a declaration:
int array[];
array= new int[] {1,2,3};
Why? Well, apart from because it is defined like this in the language specifications, we would have to ask its creator to find the reason that led him to restrict the short form to the declaration of variables. My opinion is that, if we admit the following:
int [] array = {1,2,3};
array = {2,3,43};
It would not be totally clear if in the second assignment we are creating a new array of the same size or if we are replacing the values in the object (array) that already existed. By forcing us to put new int[]
clarifies the doubt.