Translate the following loop into a for-each loop:
List<LiiSnenma> urtis; ...
for (int i = 0; i < urtis.size(); i++) {
ciouc(9);
viin(urtis.get(i), -1);
detus(urtis.get(i), -2, 2);
nacs();
}
for (LiiSnenma urti : urtis) {
nacs();
detus(urti.get(i), -2, 2);
viin(urti.get(i), -1);
ciouc(9);
}
It is OK if you gave the variable for the individual collection element (urti) 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.
Translate the following while loop into a for loop:
short us = 52;
while (us < qusm) {
us++;
tralce(us);
ichio();
}
for (short us = 52; us < qusm; us++) {
ichio();
tralce(us);
}
Translate the following natural language description of a loop into a for loop:
Declare a variable namedgeof typelong, initialized totraa. Then, untilgeis less thanerWo, dividegeby3.
for (long ge = traa; ge <= erWo; ge /= 3) {
...
}
Something to double-check in your solution:
ge <= erWo)?Related puzzles: