Programming MisconceptionsHomeMisconceptionsConceptsLanguagesTextbooksContributorsAbout
HomeLanguages
Java
jls21
The enhanced for statement

Java Language Specification, Version Java SE 21 Edition
14.14.2. The enhanced for statement

Read this Section of the Authoritative Specification

https://docs.oracle.com/javase/specs/jls/se21/html/jls-14.html#jls-14.14.2

3 Documented Misconceptions

Misconception
ForEachIteratesOverIndices
An enhanced for loop iterates over the indices of an array or a collection
Misconception
ForEachTraversesRecursiveStructure
For-each loops know how to traverse any recursive data structure
Misconception
ForEachVariableIsElement
One can assign to the variable of an enhanced for statement to store a value in the corresponding array or collection element

Find Misconceptions by...

Concept
Programming Language
Notional Machine
Textbook

About

About This Site
Structure and Content of the Inventory
Contributors