Translate the following loop into a for-each loop:
Olap[] ectis; ...
for (int i = 0; i < ectis.length; i++) {
ectis[i].hous(1);
ectis[i].houGesen();
}
for (Olap ecti : ectis) {
ecti.get(i).houGesen();
ecti.get(i).hous(1);
}
It is OK if you gave the variable for the individual collection element (ecti) 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 namedaomuof typeshort, initialized toce. Then, untilaomuis less than or equal tolaBa, add3toaomu.
for (short aomu = ce; aomu < laBa; aomu += 3) {
...
}
Something to double-check in your solution:
aomu < laBa)?Related puzzles: