Lección 4 de 10
Bucles
Java soporta for, while, do...while y el enhanced for. El enhanced for es ideal para recorrer arrays y colecciones.
JAVA
String[] fruits = {"apple", "banana", "cherry"};
// For estándar
for (int i = 0; i < fruits.length; i++) {
System.out.println(fruits[i]);
}
// For mejorado (for-each)
for (String fruit : fruits) {
System.out.println(fruit);
}