Computer Science Canada For loops |
Author: | cool dude [ Fri May 05, 2006 6:56 pm ] | ||||
Post subject: | For loops | ||||
can someone please tell me what the difference is between doing it these 2 ways? because the first way doesn't work and i don't see much of a difference ![]()
Or the correct way
|
Author: | Tony [ Fri May 05, 2006 8:14 pm ] | ||
Post subject: | |||
well because it's like for ( declare local? variable; condition; some operation) so placing i where variable declaration is expected instead is wrong I think that
might work, it should in C ![]() just be careful about your counter's scope |
Author: | rizzix [ Fri May 05, 2006 8:45 pm ] | ||||
Post subject: | Re: For loops | ||||
cool dude wrote:
Maybe you meant this:
|
Author: | cool dude [ Fri May 05, 2006 8:57 pm ] |
Post subject: | |
so this is one of those pointless rules. i don't really see much of a difference in declaring a variables and then making the counted/for loop with it. thanks for explaining ![]() P.S. how would you draw shapes in java? ![]() |
Author: | [Gandalf] [ Sat May 06, 2006 12:38 am ] |
Post subject: | |
cool dude wrote: P.S. how would you draw shapes in java?
![]() You create either an applet or a Frame, JFrame, or some other kind of GUI container, and use the paint() method using the Graphics class. |
Author: | rizzix [ Sat May 06, 2006 3:11 pm ] | ||
Post subject: | |||
cool dude wrote: so this is one of those pointless rules. i don't really see much of a difference in declaring a variables and then making the counted/for loop with it. It's not really a pointless rule. It is a rule.
If you wish you may also write that snippet as follows:
See the difference?... |