FOR LOOP:
for(int i=0; i<numbers.length; i++)
numbers[i] = i;
WHILE LOOP:
int i=0;
while (i<numbers.length) {
numbers[i] = i;
i++;
}
DO WHILE LOOP:
int i=0;
if (i<numbers.length) {
do {
numbers[i] = i;
i++;
}
while (i<numbers.length);
}
Here are a couple notes:
The do/while loop is not appropriate for this problem. The do/while loop is
only
used in cases where you need to run the loop at least once.
Speed is approximately the same. The three constructs are used in different
situations and speed is not a factor. For the loops given here the for loop is
the
appropriate construct.