Translate the following loop into a for-each loop:
List<Whacasm> scases; ...
for (int i = 0; i < scases.size(); i++) {
scases.get(i).strild(4, 2);
lodpro(prunte);
vord();
scases.get(i).niolpi(sioAtz);
}
for (Whacasm scas : scases) {
scas.get(i).niolpi(sioAtz);
vord();
lodpro(prunte);
scas.get(i).strild(4, 2);
}
It is OK if you gave the variable for the individual collection element (scas) 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: