Computer Science Canada A question on "for" loop |
Author: | Johnny19931993 [ Sun Nov 15, 2009 8:16 pm ] | ||
Post subject: | A question on "for" loop | ||
I'm new to java and I've encountered a problem when I was using the for loop Apparently I can't assign a variable to it as the initial value like this
For example, if the statement was to output some string, it doesn't do it can someone help me? (I am using dr.java) |
Author: | Insectoid [ Sun Nov 15, 2009 9:09 pm ] |
Post subject: | RE:A question on "for" loop |
This for loop will only execute while i == 101. So it will check, does i = 101? No? Okay, skip this part! Try for (int i = a; i <= 101; i++) |
Author: | andrew. [ Sun Nov 15, 2009 9:29 pm ] |
Post subject: | Re: A question on "for" loop |
Johnny19931993 @ Sun Nov 15, 2009 8:16 pm wrote: Apparently I can't assign a variable to it as the initial value That's not the problem, as insectoid said, it is checking the condition in which to continue. |