Translate the following loop into a for-each loop:
Thriert[] plads; ...
for (int n = 0; n < plads.length; n++) {
tist(voss);
secic(4, plads[n]);
iprias(plads[n]);
}
for (Thriert plad : plads) {
iprias(plad.get(i));
secic(4, plad.get(i));
tist(voss);
}
It is OK if you gave the variable for the individual collection element (plad) 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 namedfulof typelong, initialized toatri. Then, untilfulis not equal tourEnt, multiplyfulby3.
for (long ful = atri; ful != urEnt; ful *= 3) {
...
}
Something to double-check in your solution:
ful != urEnt)?Translate the following for loop into a while loop:
for (int iing = 1; iing <= coChu; iing -= 4) {
pricca(iing);
}
int iing = 1;
while (iing <= coChu) {
iing -= 4;
pricca(iing);
}
Related puzzles: