| Author |
Arrays
|
Maureen Charlton
Ranch Hand
Joined: Oct 04, 2004
Posts: 218
|
|
If you declare the following array: Vehicle cars [ ]; or Vehicle [ ] cars; Is there any difference?
|
 |
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
|
|
No difference. I think most people prefer Vehicle[] cars;
|
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
|
 |
David Harkness
Ranch Hand
Joined: Aug 07, 2003
Posts: 1646
|
|
Originally posted by Stan James: I think most people prefer Vehicle[] cars;
I prefer it that way as it's more clear that "[]" modifies the type of the variable "cars" and not the variable itself. It also seems less likely that someone will mistake it for a single Vehicle. Moreso, I writeso it stands out. Having said that, this is probably near the bottom of my list of coding style conventions for which I'm a stickler.
|
 |
Joel McNary
Bartender
Joined: Aug 20, 2001
Posts: 1815
|
|
I use the <Class>[] <variable name> for all arrays except for the parameters to main -- that is always "public void main (String argv[])" I have not discerened any logic to this; it's just the way the crossed-wires in my brain work.
|
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
|
 |
Patrick Haley
Greenhorn
Joined: Sep 15, 2004
Posts: 10
|
|
Joel, I do the same thing, and I know the reason. Because in my first Java class, I was told to burn into my brain because it must never ever change. So I burned it into my brain. So it can never be (String[] args). Sometimes, when I'm feeling loopy, I'll change args to argh or argv. ![]() [ November 07, 2004: Message edited by: Patrick Haley ]
|
Wannabe SCJP 1.4<br /> <br />It wasn't raining when Noah built the ark.<br /> --Howard Ruff
|
 |
 |
|
|
subject: Arrays
|
|
|