Friday, 15 August 2014

java - Best idiom for a decrementing loop -


What is the best / favorite idioms for the loop sink, and why?

 for  (int idx = (len-1); idx> = 0; idx--) {...}  

or

 for  (int idx = (lane -1); idx> 1; idx--) {...}  

or (For the use of sylvarking answers, but to interrupt the index scope)

 for  (int idx = len; idx -> 0;) {...} < / Code> 

What is the possibility of traveling one or another another developer?

I give the following suggestions because the comparison against zero is optimized at the byte code level.

 for  (int idx = (len-1); idx> = 0; idx--) {...}  

this Jack is a suggestion by Shirke


No comments:

Post a Comment