for loop:
int sum = 0;
for (int index = 0; index < arr.length; index++)
{
sum += arr[index];
}
for-each loop:
int sum =0;
for (int index:arr)
{
sum += index;
}
I also referenced the following link:
http://forums.devarticles.com/java-development-38/java-changing-while-loop-to-for-loop-169122.html
Good job, and thanks for sharing the resource for others to see. 100 XPs awarded for this completion.
ReplyDelete