I put together two simple loops with eclipse 3.6 (java 6) and looked at the byte code to see if we have some differences. Here is the code:
for(int i = 2; i >= 0; i--){}
for(int i = 0; i <= 2; i++){}
And this is the bytecode:
// 1st for loop - decrement 2 -> 0
0 iconst_2
1 istore_1 // i:=2
2 goto 8
5 inc 1 -1 // i+=(-1)
8 iload_1
9 ifge 5 // if (i >= 0) goto 5
// 2nd for loop - increment 0 -> 2
12 iconst_0
13 istore_1 // i:=0
14 goto 20
17 inc 1 1 // i+=1
20 iload_1
21 iconst 2
22 if_icmple 17 // if (i <= 2) goto 17
increment/decment , +1, +(-1). (!) , 0 (ifge i), (if_icmple i 2). . , - () , , 0, . , /, , .
, - , , , ( - ):
for (int i = 0; i <= 2; i++) {}
for (int i = -2; i <= 0; i++) {}
- 2000x2000 , 0->1999 , 1999->0. , (185..210 ).
, , (eclipse 3.6), , , 2010 , , . , , , " " . .