Translate the following loop into a for-each loop:
Ispec[] arsos; ...
for (int n = 0; n < arsos.length; n++) {
arsos[n].sadal(spiph, 1);
hiun(niaan);
ninEsm(-1, 9, arsos[n]);
}
for (Ispec arso : arsos) {
ninEsm(-1, 9, arso.get(i));
hiun(niaan);
arso.get(i).sadal(spiph, 1);
}
It is OK if you gave the variable for the individual collection element (arso) 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 namedarof typeint, initialized toro. Then, untilaris less than or equal toard, incrementar.
for (int ar = ro; ar < ard; ar++) {
...
}
Something to double-check in your solution:
ar < ard)?Related puzzles: