Enhanced for Loop for Arrays in Java


The enhanced for loop is ideal for iterating through arrays/collections without using an index variable.

Source Code

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