Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is an array

 
Yudi Strange
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whats the difference between

String [] a;

and

String a;

Kindly explain.

[edited subject - was doubt]
 
Marco Ehrentreich
best scout
Bartender
Posts: 1294
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 9528
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yudi please Use A Meaningful Subject Line for your posts to get better response...
 
Yudi Strange
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Yudi,

You Should read Way of Declare a Array

Hope this helps
 
Marco Ehrentreich
best scout
Bartender
Posts: 1294
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!!!
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic