---
id: java-for-each-loop
title: "Java For Each Loop"
category: "Programming_Language"
status: "draft"
verification_status: "conceptual"
canonical_id: ""
aliases: ["for-each loop", "enhanced for loop", "자바 for-each"]
duplicate_of: ""
source_trust_level: "B"
confidence_score: 0.88
created_at: 2026-07-04
updated_at: 2026-07-04
review_reason: ""
merge_history: []
tags: ["java", "programming", "w3schools", "loops", "for-each", "arrays"]
raw_sources: ["https://www.w3schools.com/java/java_foreach_loop.asp"]
applied_in: []
github_commit: ""
---

# [[Java For Each Loop]]

## 🎯 한 줄 통찰 (One-line insight)
The for-each loop trades index-based flexibility for readability — you can't access a counter variable like `i < array.length`, but for pure "visit every element" iteration it eliminates the boilerplate of managing an index entirely. [S1]

## 🧠 핵심 개념 (Core concepts)
- **`for (type variableName : arrayName) { ... }`** — iterates every element of an array without an explicit counter. [S1]
- **Exclusive to arrays/collections** — used specifically to loop through elements, not general counting loops. [S1]
- **Simpler and more readable** — no need for a counter comparison like `i < array.length`. [S1]

## 📖 세부 내용 (Details)
- String array: `String[] cars = {"Volvo", "BMW", "Ford", "Mazda"}; for (String car : cars) { System.out.println(car); }`. [S1]
- Int array: `int[] numbers = {10, 20, 30, 40}; for (int num : numbers) { System.out.println(num); }`. [S1]

## ⚖️ 모순 및 업데이트 (Contradictions & updates)
소스에서 모순되는 정보는 발견되지 않음.

## 🛠️ 적용 사례 (Applied in summary)
현재 발견된 실제 적용 사례가 없습니다 — 배열의 모든 원소를 순회 출력할 때 표준적으로 쓰이는 문법(Arrays 챕터에서 본격 확장됨). [S1]

## 💻 코드 패턴 (Code patterns)
For-each over a String array (Java):
```java
String[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
for (String car : cars) {
    System.out.println(car);
}
```

## ✅ 검증 상태 및 신뢰도
- **상태:** draft
- **검증 단계:** conceptual
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
- **신뢰 점수:** 0.88
- **중복 검사 결과:** 신규 생성 (New discovery)

## 🔗 지식 그래프 (Knowledge Graph)
- **상위/루트:** [[Java Tutorial]]
- **관련 개념:** [[Java For Loop]], [[Java Arrays]], [[Java Arrays Loop]]
- **참조 맥락:** 배열 순회 전용 문법 — Arrays 챕터의 선행 개념.

## 📚 출처 (Sources)
- [S1] W3Schools — Java For Each Loop — https://www.w3schools.com/java/java_foreach_loop.asp

## 📝 변경 이력 (Change history)
- 2026-07-04: Initial draft synthesized from the W3Schools "Java For Each Loop" page (Astra wiki-curation, P-Reinforce v3.1 format).
