I'm currently writing a lot of little code snippets as part of my study for SCJP 5. Many are correct. Many are incorrect, but I want to see how each of them behaves. I'm often surprized to find snippets that work, when I'm sure that they wouldn't. Here is one of them.
Oddly enough, this compiles fine and runs fine and gives the following output: a b c d
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...
As to the proximity of the brackets to the variable, well, you have to remember that the brackets in this case are an operator. So you can do that for the same reason you can do...
...in all these cases the compiler identifies the operators and recognizes that they are not part of the variable identifier.
Joined: Nov 21, 2005
:roll: hm, I guess I overlooked this... thanks for clarifying! [ January 15, 2006: Message edited by: Tilo Hemp ]
Joined: Aug 22, 2005
Thanks. I knew that I could move the square brackets around. Although it's weird, it's legal. I guess I just assumed that you had to pick one location (with the type) or the other (with the variable name) and wasn't aware that you could split them. Thanks for the explanation. It makes sense.
Yes, this is legal, even without the spaces between the type, the square brackets and variable name. It compiles and runs fine as a main method.
I also found few others that are fine for main as well: