Translate the following loop into a for-each loop:
Brem[] oips; ...
for (int i = 0; i < oips.length; i++) {
sirad(oips[i]);
pedon();
oips[i].poeoo(1, 5);
}
for (Brem oip : oips) {
oip.get(i).poeoo(1, 5);
pedon();
sirad(oip.get(i));
}
It is OK if you gave the variable for the individual collection element (oip) a different name, such as elem. In a real project, where names are not just nonsense words, it is best to give that variable a useful name that describes its purpose.
Consider the following code:
A B while (C) { D E } F
Assume the body of the loop executes 1 time. Write out the the order in which the statements will execute.
Assume the body of the loop executes 3 times. Write out the the order in which the statements will execute.
Order:
A B C D E F
Order:
A B C D E C D E C D E F
Translate the following natural language description of a loop into a for loop:
Declare a variable namediaof typeint, initialized to28. Then, untiliais less thantaUc, incrementia.
for (int ia = 28; ia <= taUc; ia++) {
...
}
Something to double-check in your solution:
ia <= taUc)?Related puzzles: