Looping Through an ArrayList with for-each in Java


For-each provides a concise way to iterate through collections like ArrayList.

Source Code

ArrayList cars = new ArrayList(List.of("Volvo", "BMW", "Ford"));
for (String car : cars) {
    System.out.println(car);
}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments