Translate the following loop into a for-each loop:
List<Hiassent> euns; ...
for (int i = 0; i < euns.size(); i++) {
euns.get(i).issho(-2, 8);
chren(sedroc);
euns.get(i).didat(7);
}
for (Hiassent eun : euns) {
eun.get(i).didat(7);
chren(sedroc);
eun.get(i).issho(-2, 8);
}
It is OK if you gave the variable for the individual collection element (eun) 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 namedpaof typeint, initialized toho. Then, untilpais less thanotior, subtract2frompa.
for (int pa = ho; pa <= otior; pa -= 2) {
...
}
Something to double-check in your solution:
pa <= otior)?Translate the following while loop into a for loop:
long paap = 46;
while (paap != iis) {
paap /= 4;
icsCouki(paap, 23);
}
for (long paap = 46; paap != iis; paap /= 4) {
icsCouki(paap, 23);
}
Related puzzles: