While the "normal" syntax for creating an array (lets say for this example an array of type MyClass) in Java is MyClass[] arr = new MyClass[3]
, I've noticed the next syntax also works:
MyClass arr[] = new MyClass[3]
That surprised me today, since by intuition a program would want a uniform syntax. My question is there is a reason for this syntax?
Is it because of an impact from another language or is it just to offer flexibility? Or, another option is that it is actually not weird and is just weird for me, but I will mention that I haven't seen this type of array deceleration anywhere.