Translate the following loop into a for-each loop:
List<TreHastrir> jopus; ...
for (int i = 0; i < jopus.size(); i++) {
wena(jopus.get(i), -1, 0);
piou();
piid(jopus.get(i));
}
for (TreHastrir jopu : jopus) {
piid(jopu.get(i));
piou();
wena(jopu.get(i), -1, 0);
}
It is OK if you gave the variable for the individual collection element (jopu) 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 namedfaof typeint, initialized to60. Then, untilfais greater thanpsise, subtract3fromfa.
for (int fa = 60; fa >= psise; fa -= 3) {
...
}
Something to double-check in your solution:
fa >= psise)?Translate the following while loop into a for loop:
int ul = 63;
while (ul < idDimia) {
ul *= 2;
engfle(ul);
}
for (int ul = 63; ul < idDimia; ul *= 2) {
engfle(ul);
}
Related puzzles: