Apr 18: Using Iterators
Learning Objectives
After today's class, you should be able to:
- Explain the
Iterable
interface and how to use anIterator
. - Apply
Set
operations to solve problems involving duplicates. - Build a
Map
that represents the frequency of words in a string.
Reminders¶
- By Friday 11pm: Do the Week 13 reading and take Quiz10
- By Friday 11pm: Finish and submit Lab 10: Word Clouds
- By Monday 11pm: Submit HW 9 Part A (5 files, 40 pts)
Lesson Outline¶
Mini Lecture [25 min]
- java.util.Iterator
/ java.lang.Iterable
- How to update a collection using an iterator
- Card.java
/ Deck.java
/ Main.java
- Iterator makes "for each card in deck" possible
- IteratorDemo.java working with collections
- Manual:
while (iter.hasNext())
anditer.next()
- Automatic:
for (variable : iterable)
- Manual:
- Lesson: Implementations (Hash vs Tree)
Finish Lab10 [50 min]
- Lab 10: Word Clouds
- Did the first 33% on Tuesday; finish the other 67% today.