Results 1 to 5 of 5
- 12-12-2008, 05:29 PM #1
simple loop syntax( ; ;), ( something : somthing)
I'm curious as to all the different ways to write a for loop? I know how the standard
works. Could someone explainJava Code:for(starting value; value to reach; increment value){ }
I'm assuming it automatically starts at 0, something1 is the value to reach, and something2 is the increment value? Or maybe it increments++ start at something1 until it reaches something2?Java Code:for(something1 : something2){ }
If there are any other styles of writing a for loop(also that :? thing in if statements is confusing) feel free to toss them in here with a little explanation also.
- 12-12-2008, 08:24 PM #2
Senior Member
- Join Date
- Nov 2007
- Posts
- 160
- Rep Power
- 6
I'd also like to know...
- 12-13-2008, 08:23 AM #3
Senior Member
- Join Date
- Nov 2007
- Posts
- 160
- Rep Power
- 6
Look here:
The for Statement (The Java™ Tutorials > Learning the Java Language > Language Basics)
That gives a basic rundown of the two types.
for(item : array) is used to iterate through an array or collection.
- 12-13-2008, 08:55 AM #4
- 12-13-2008, 12:19 PM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Similar Threads
-
[SOLVED] Looking for web.xml syntax doc
By Norm in forum Java ServletReplies: 2Last Post: 08-21-2008, 07:59 PM -
[SOLVED] Beginner needs help on Loop,Math-syntax on Graphics
By obdi in forum New To JavaReplies: 13Last Post: 07-06-2008, 09:11 AM -
Cannot get passed these syntax errors
By MrKP in forum New To JavaReplies: 1Last Post: 05-12-2008, 07:05 AM -
syntax error
By gabriel in forum New To JavaReplies: 3Last Post: 08-03-2007, 03:26 PM -
Help with removing somthing once inputed.
By fegiflu in forum New To JavaReplies: 8Last Post: 07-26-2007, 10:58 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks