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 ?
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 ?
If, for example, i = 5
:
--i
decrements i by 1 then gives you the value of i (4).
i--
gives you the value of i (5) then decrements it by 1.
Both will give you the same result in a for loop.