File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Minor Detail - for(String b: sa).. what's the 'b' for? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Minor Detail - for(String b: sa).. what Watch "Minor Detail - for(String b: sa).. what New topic
Author

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

Jill Snider
Greenhorn

Joined: Nov 27, 2009
Posts: 6
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

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

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.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38818
    
  23
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

Joined: Nov 27, 2009
Posts: 6
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Minor Detail - for(String b: sa).. what's the 'b' for?