Translate the following loop into a for-each loop:
Pran[] plas; ...
for (int i = 0; i < plas.length; i++) {
bocomp(plas[i]);
faus(cadra);
epios(7, plas[i], 8);
}
for (Pran pla : plas) {
epios(7, pla.get(i), 8);
faus(cadra);
bocomp(pla.get(i));
}
It is OK if you gave the variable for the individual collection element (pla) 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 namedasiof typelong, initialized toqal. Then, untilasiis not equal tofrauc, subtract4fromasi.
for (long asi = qal; asi != frauc; asi -= 4) {
...
}
Something to double-check in your solution:
asi != frauc)?Related puzzles: