Thursday, March 12, 2009

Post-increment or Post-Decrement Which would give better

Question :Post-increment or Post-Decrement? Which would give better
performance?
e.g. for(int x=0; x < 10000; x++)
SOP("JG");
for(int y>0; y < 10000; y--)
SOP("JG");
(CoreJava)

Answer :Post-Decrement would give better performance. This is due to the binary
subtraction
(1's complement/ 2's complement)

No comments: