Nothing much to add to what others have said.
However, I believe that you should use new int[]{10,3,4,12,2} (like the others declared), and Java does not allow you to use only {10,3,4,12,2} , so this that Java is heavily typed.
If you just use {10,3,4,12,2} , there is no concept of what the type of an array element can be. They seem to be integers, but they can be int , long , float , double , etc.
Well, actually it can infer the type from the method signature and start compiling if it doesn't work, but it seems complicated.
source share