mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
Improve description of the for loop.
This commit is contained in:
parent
b72c575c04
commit
7560b334db
@ -225,11 +225,12 @@ public class LearnJava {
|
|||||||
System.out.println("fooFor Value: " + fooFor);
|
System.out.println("fooFor Value: " + fooFor);
|
||||||
|
|
||||||
// For Each Loop
|
// For Each Loop
|
||||||
// An automatic iteration through an array or list of objects.
|
// The for loop is also able to iterate over arrays as well as objects
|
||||||
|
// 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> : <array_object>)
|
// for each loop structure => for (<object> : <collection>)
|
||||||
// reads as: for each object in the array
|
// reads as: for each element in the collection
|
||||||
// note: the object type must match the array.
|
// note: the object type must match the element type of the collection.
|
||||||
|
|
||||||
for (int bar : fooList) {
|
for (int bar : fooList) {
|
||||||
System.out.println(bar);
|
System.out.println(bar);
|
||||||
|
Loading…
Reference in New Issue
Block a user