This may be an embarrassing thing to admit, but I was momentarily stumped this morning when I had a need to iterate over the English alphabet with Java 1.5 ... I've been a Sun Microsystems Certified Java Programmer for 3 years now, yet this little thing got me!
Well, here's my solution, which I'm posting up now in hopes that someone with the same need may do a google search and find this post =)
char letter;
for (letter='a'; letter <= 'z'; letter++) { System.out.println( letter ); }
Simple, right!?
If you find this helpful, please leave a comment and let me know!
11 comments:
This post will help me so much ... I am in almost the same situation as yours ...
Thanks.
Yes man,
this is helpful :-)
Thanks!
thanks a lot!
Thank you
nice.. :) thx I did find it when looking for it.
I had this when I needed it :)
Very helpful, you did the right thing in sharing... :)
Thanks! =)
This is very helpful!
Wow.. I have the same need, thanks!))
Nice and simple, thank you for sharing!
nice just what I needed, btw you can put the datatype declaration of letter within the loop's definition.
for(char letter... )
Post a Comment