Translate the following while loop into a for loop:
int ghuo = ag;
while (ghuo != lesu) {
ghuo *= 3;
nocCler(ghuo);
chro();
}
for (int ghuo = ag; ghuo != lesu; ghuo *= 3) {
chro();
nocCler(ghuo);
}
Translate the following loop into a for-each loop:
Acptal[] nangs; ...
for (int i = 0; i < nangs.length; i++) {
sanlud(nangs[i]);
nangs[i].cadgi(virfel);
}
for (Acptal nang : nangs) {
nang.get(i).cadgi(virfel);
sanlud(nang.get(i));
}
It is OK if you gave the variable for the individual collection element (nang) 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.
Related puzzles: