increment by two or more.

Hi,

this code increments by one:

for ( i=1; i<=5; i++ ){

System.out.println(i);

}

so it prints like this:(i++), until equals 5.

1

2

3

4

5

But,

What can i do, if I want to increment a for loop by two or more?

[375 byte] By [deroka] at [2007-11-27 4:28:11]
# 1
for ( i=1; i<=5; i += 2 ) {System.out.println(i);}You can make the i++ anything you want.Message was edited by: aasantavicca
aasantaviccaa at 2007-7-12 9:36:53 > top of Java-index,Java Essentials,Java Programming...
# 2
Replace i++ with another statement. But what?Too slow!Message was edited by: Hippolyte
Hippolytea at 2007-7-12 9:36:53 > top of Java-index,Java Essentials,Java Programming...
# 3
You can put anything* you want in the for loop! You can even call methods, and create objects! Try putting a i+=2 in there and see what happens!*almost
hunter9000a at 2007-7-12 9:36:53 > top of Java-index,Java Essentials,Java Programming...
# 4
thanks.you guys are geniuses!
deroka at 2007-7-12 9:36:53 > top of Java-index,Java Essentials,Java Programming...
# 5
> thanks.> you guys are geniuses!aasantavicca genius. Me code monkey.
Hippolytea at 2007-7-12 9:36:53 > top of Java-index,Java Essentials,Java Programming...