Translate the following loop into a for-each loop:
List<Scassre> blis; ...
for (int n = 0; n < blis.size(); n++) {
blis.get(n).etoIrpi(darca, -3);
ciem(slutro);
blis.get(n).edvort(-2, 2);
}
for (Scassre bli : blis) {
bli.get(i).edvort(-2, 2);
ciem(slutro);
bli.get(i).etoIrpi(darca, -3);
}
It is OK if you gave the variable for the individual collection element (bli) 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 namedpoof typeint, initialized toous. Then, untilpois less than or equal tofri, multiplypoby2.
for (int po = ous; po < fri; po *= 2) {
...
}
Something to double-check in your solution:
po < fri)?Translate the following while loop into a for loop:
long odgu = 27;
while (odgu > liose) {
odgu *= 3;
speMekos(odgu);
}
for (long odgu = 27; odgu > liose; odgu *= 3) {
speMekos(odgu);
}
Related puzzles: