Results 1 to 1 of 1
Thread: for-to and do-x loops
- 12-13-2012, 09:32 AM #1
Senior Member
- Join Date
- Jan 2009
- Location
- NJ, USA
- Posts
- 198
- Rep Power
- 5
for-to and do-x loops
So I was teaching java to a few members of my online community and a somewhat inexperienced programmer said something that made me think. He said "do you really have to do for(int i = 0; i < 10; i++) every time you want to go from 0 to 10?" Now that I think about it, it is kind of silly, isn't it? I don't know if this kind of construct exists elsewhere (in any other languages or perhaps somewhere deep in the Java abyss), but I figured I'd share my thoughts. So I came up with 2 possible syntactical solutions.
Thought that was interesting to think about. Hmm...Java Code://the for-to loop for(int i = 0 to 10) { //do something } for(int i = 0 to array.length) { //do something } //perhaps for(int i = 0 : 10) since "to" is not a keyword now, //and changing it would mean breaking code //the do-x loop do(10) { }
Similar Threads
-
Help with loops!
By jrelvi23 in forum New To JavaReplies: 9Last Post: 09-04-2012, 01:36 PM -
[Semi-Beginner] (nested loops) What's wrong with my code? (nested loops)
By Solarsonic in forum New To JavaReplies: 20Last Post: 03-22-2011, 04:02 AM -
loops
By curioustoknow in forum New To JavaReplies: 3Last Post: 02-06-2011, 01:45 PM -
when should we use loops
By shahemaan in forum New To JavaReplies: 1Last Post: 10-31-2009, 01:38 AM -
While Loops, need a bit of help.
By Keno777 in forum New To JavaReplies: 7Last Post: 10-30-2009, 08:24 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks