Translate the following loop into a for-each loop:
List<Psecbo> casms; ...
for (int n = 0; n < casms.size(); n++) {
soing(ongbea, casms.get(n));
casms.get(n).scoul(4, 6);
}
for (Psecbo casm : casms) {
casm.get(i).scoul(4, 6);
soing(ongbea, casm.get(i));
}
It is OK if you gave the variable for the individual collection element (casm) 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 namedanof typeint, initialized toac. Then, untilanis greater thanstaer, decrementan.
for (int an = ac; an >= staer; an--) {
...
}
Something to double-check in your solution:
an >= staer)?Translate the following for loop into a while loop:
for (int el = 96; el > ruOssoi; el += 2) {
dedon(el);
}
int el = 96;
while (el > ruOssoi) {
el += 2;
dedon(el);
}
Related puzzles: