Control Flow
Loops
For Loop
java
for(int i = 0; i < 10; i++) {
// do something
}
List<String> myStrings = new ArrayList<>(List.of("hello", "world"));
for (String s : myStrings) {
// do something
}
for (var s : myStrings) {
// do something
}
Interable Interfaces
Many collections implement the Iterable
interface, which has a method for each.
java
List<String> words = new ArrayList<>(List.of("hello", "world"));
words.forEach((s) -> System.out.println(s));