Example - Iteration

I. Task
Iterate through each item of a collection.

  • Go through all records
  • For each record, change to readable format (use name for value)
  • Print out readable format

II. Notes

  • Java 7 - external iterator - for loop
  • Java 8 - internal iterator -
    • ForEach (T -> void)
    • ForEach (Consumer<T>)

III. Java Codes

IV. Results