Apr 23: Using Iterators
Learning Objectives
After today's class, you should be able to:
- Explain the
Iterable
interface and how to use anIterator
. - Apply methods from a poorly documented third-party library.
- Implement common interfaces in the
java.lang
package.
Lesson Outline¶
Mini Lecture [10 min]
- java.util.Iterator and 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
- Iterator makes
remove()
possible while iterating - Avoids ConcurrentModificationException
- Iterator makes
Finish Lab16 [40 min]
- Lab 16: Word Clouds
- Parts 1–3 on Monday, 4–6 today
- Submit to Gradescope by Thursday
Your To-Do List¶
- RSVP for CS Faculty Student Picnic
- Continue reading Week 13
- Make progress on HW 9