If I declare an array of objects like one of the following.
MyClass[ ] myArray;
MyClass myArray[ ];
Are both right?
If I declare an array of objects like one of the following.
MyClass[ ] myArray;
MyClass myArray[ ];
Are both right?
Both expressions are equivalent, of note is that
Object[] arr;
Object arr[];
create identical bytecode (in Java the first is usually preferred as it is clearer when reading that it's an array). JLS-10.2. Array Variables says (in part)
The [] may appear as part of the type at the beginning of the declaration, or as part of the declarator for a particular variable, or both.