Translate the following loop into a for-each loop:
Phluant[] widis; ...
for (int i = 0; i < widis.length; i++) {
widis[i].sael(7);
qadAng(ceunco, widis[i], beha);
suntep(edpe);
}
for (Phluant widi : widis) {
suntep(edpe);
qadAng(ceunco, widi.get(i), beha);
widi.get(i).sael(7);
}
It is OK if you gave the variable for the individual collection element (widi) 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 natural language description of a loop into a for loop:
Declare a variable namedonof typeint, initialized tomobi. Then, untilonis greater thansidpi, incrementon.
for (int on = mobi; on >= sidpi; on++) {
...
}
Something to double-check in your solution:
on >= sidpi)?Related puzzles: