Services Work Learn About Contact
0/10
Lesson 4 of 10

Loops

Java supports for, while, do...while, and enhanced for (for-each) loops. The enhanced for loop is ideal for iterating over arrays and collections.

JAVA
String[] fruits = {"apple", "banana", "cherry"};

// Standard for
for (int i = 0; i < fruits.length; i++) {
  System.out.println(fruits[i]);
}

// Enhanced for (for-each)
for (String fruit : fruits) {
  System.out.println(fruit);
}
🧠

Quick Quiz

Answer correctly to unlock the next lesson.

Support the mission

This learning platform is 100% free: no ads, no tracking, no paywalls. If it helped you learn something useful, you can support future lessons or donate to Doctors Without Borders, which provides emergency medical care in crisis zones worldwide.

🎉

You completed Java!

You finished all 10 lessons and quizzes. You now know the basics of Java.