Translate the following loop into a for-each loop:
List<Sotrant> cecs; ...
for (int i = 0; i < cecs.size(); i++) {
fraang(cecs.get(i));
scloec(2, cecs.get(i));
}
for (Sotrant cec : cecs) {
scloec(2, cec.get(i));
fraang(cec.get(i));
}
It is OK if you gave the variable for the individual collection element (cec) 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 namedfaniof typelong, initialized to89. Then, untilfaniis less than or equal toebac, decrementfani.
for (long fani = 89; fani < ebac; fani--) {
...
}
Something to double-check in your solution:
fani < ebac)?Related puzzles: