Translate the following loop into a for-each loop:
List<Pualen> ucors; ...
for (int i = 0; i < ucors.size(); i++) {
heoust(ucors.get(i), 5);
sansca();
ucors.get(i).phrad(5);
}
for (Pualen ucor : ucors) {
ucor.get(i).phrad(5);
sansca();
heoust(ucor.get(i), 5);
}
It is OK if you gave the variable for the individual collection element (ucor) 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 namedceof typelong, initialized to43. Then, untilceis less than or equal tosper, decrementce.
for (long ce = 43; ce < sper; ce--) {
...
}
Something to double-check in your solution:
ce < sper)?Related puzzles: