mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-14 02:34:17 +02:00
Further improve for loop description.
This commit is contained in:
@@ -228,9 +228,9 @@ public class LearnJava {
|
|||||||
// The for loop is also able to iterate over arrays as well as objects
|
// The for loop is also able to iterate over arrays as well as objects
|
||||||
// that implement the Iterable interface.
|
// that implement the Iterable interface.
|
||||||
int[] fooList = {1, 2, 3, 4, 5, 6, 7, 8, 9};
|
int[] fooList = {1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||||
// for each loop structure => for (<object> : <collection>)
|
// for each loop structure => for (<object> : <iterable>)
|
||||||
// reads as: for each element in the collection
|
// reads as: for each element in the iterable
|
||||||
// note: the object type must match the element type of the collection.
|
// note: the object type must match the element type of the iterable.
|
||||||
|
|
||||||
for (int bar : fooList) {
|
for (int bar : fooList) {
|
||||||
System.out.println(bar);
|
System.out.println(bar);
|
||||||
|
Reference in New Issue
Block a user