-2

In some code i've seen a for loop with a --i as third parameters

for(int i=array.length; i<0; --i)

Maybe someone can explain me the difference with i-- ?

i guess it's something like the moment when i is decremented ?

4

1 回答 1

14

例如,如果i = 5

--i将 i 减 1,然后给您 i (4) 的值。

i--给出 i (5)的值,然后将其减 1。

两者都会在 for 循环中为您提供相同的结果。

于 2013-05-27T15:56:00.000 回答