| Author |
what is an array
|
Yudi Strange
Greenhorn
Joined: Jun 04, 2009
Posts: 7
|
|
Whats the difference between
String [] a;
and
String a;
Kindly explain.
[edited subject - was doubt]
|
 |
Marco Ehrentreich
best scout
Bartender
Joined: Mar 07, 2007
Posts: 1220
|
|
Hi Yudi,
the one with the [] is called an array! Basically an array contains multiple Strings whereas the one without [] is exactly one object of type String.
You'll find more information on the website I posted ;-)
Marco
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
|
Yudi please Use A Meaningful Subject Line for your posts to get better response...
|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|
 |
Yudi Strange
Greenhorn
Joined: Jun 04, 2009
Posts: 7
|
|
@Ankit: I'll keep that in mind next time. Thanks for the heads up.
@Marco:
then what does String a[] means? Is it the same as String [] a?
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
Dear Yudi,
You Should read Way of Declare a Array
Hope this helps
|
 |
Marco Ehrentreich
best scout
Bartender
Joined: Mar 07, 2007
Posts: 1220
|
|
Both notations are identical and mean exactly the same. But in general
should be preferred instead of
because the the array brackets are part of the type declaration. So it's less confusing to put the brackets directly to the base type "String".
Marco
|
 |
Yudi Strange
Greenhorn
Joined: Jun 04, 2009
Posts: 7
|
|
Thanks!!!
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26192
|
|
Yudi Strange wrote:@Ankit: I'll keep that in mind next time. Thanks for the heads up.
I edited the subject this time so other newcomers don't think that is the best way to ask a questin.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
 |
|
|
subject: what is an array
|
|
|