• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Minor Detail - for(String b: sa).. what's the 'b' for?

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all!

New to the forum and I hope someone can explain this minor detail to me.





It's that darn 'b' in the for loop.
I can change it to any value but am not sure what it's purpose is?

Thanks for your help!
Jill

 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's the name of the String variable which can be used inside the loop to refer to each of the String objects in the iteration. Example (note the use of the Code tags and please use them next time):


And welcome to JavaRanch.
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

Always use the code button when you quote code (but you can't use coloured code). I have edited your post and you can see how much better it looks.
 
Jill Snider
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Paul and Campbell,

Thanks for your help.

Of course the 'b' was for each String object! I did something stupid whilst trying to print it out.
Thank you for the clarity.

Also, I will use the code format next time I post.

Thanks again, Jill
reply
    Bookmark Topic Watch Topic
  • New Topic