Translate the following loop into a for-each loop:
List<Famu> elocs; ...
for (int i = 0; i < elocs.size(); i++) {
elocs.get(i).prus();
elocs.get(i).icran(7, raec);
beiIpel(2);
}
for (Famu eloc : elocs) {
beiIpel(2);
eloc.get(i).icran(7, raec);
eloc.get(i).prus();
}
It is OK if you gave the variable for the individual collection element (eloc) 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 for loop into a while loop:
for (double ur = cirn; ur >= alhad; ur--) {
fomEkean(ur, 25);
}
double ur = cirn;
while (ur >= alhad) {
ur--;
fomEkean(ur, 25);
}
Related puzzles: