Q&A

Q1:Are there any specific cases in which one loop is appropriate over another?
A1: Usually, when you have to walk an index or sequential set of elements (such as referencing all elements in an array), the for loop is the best choice.
Q2:Should I be concerned about the performance differences between the two types of loops?
A2: With today's fast processors, chances are good that the performance difference between the two loop types in any given situation will be overshadowed by the readability and functionality of the best choice of loop. If you have a situation in which performance is critical, write the loop using all the ways you can think of, benchmark the results, and choose the fastest loop.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.21.159.82