Java Reference
In-Depth Information
There are a few points to note in this example. Array indices start their numbering at zero,
so make sure that the value in the for loop also starts at zero. We want the loop to continue
until it reaches the length of the array; this can be set as the variable max in the initializ-
ation part of the for loop, then the condition becomes i < max . This is preferable to
using i < pizzas.length because then the length of the pizzas array would have to
be calculated after every pass through the loop. This might not sound all that important, but
it can make a big difference to the speed of the program when using large arrays.
Search WWH ::




Custom Search