Author | Message |
---|---|
khsu
Posts: 30
|
Posted 18:59 Feb 28, 2014 |
The second part of the question asks for an enhanced for loop starts at value[1] instead of value[0]. for ( int i = 1; i < values.length; i ++ ) { total = total + values[i]; } Is there an enhanced for loop for this? I assume enhanced for loops reads all the values in the array. |
Eric Liao
Posts: 158
|
Posted 19:26 Feb 28, 2014 |
Correct. Enhanced for loop will iterate through all items in the list. This means that you have to find a way to skip the first item (e.g. create a sub array and use enhanced for loop or using if statement to skip the first item). |