# Enhanced for Loop

A loop that visits each element of an array or iterable collection.

## What is **Enhanced for Loop** in Java?

**Enhanced for Loop** — A loop that visits each element of an array or iterable collection.

```java
class PetRegistry {
    int countNames(String[] pets) {
        int count = 0;

        for (String pet : pets) {
            count++;
        }

        return count;
    }
}
```

Level: Apprentice · [More Java terms at this level](https://www.ask-codey.com/glossary/subjects/java/apprentice)

Updated: September 27, 2026

Source: https://www.ask-codey.com/glossary/enhanced-for-loop
