🍄 🐘 🦆 🐟 🐍 🦋 🐸 🦖🌳 🌸 🍓 🥒 🍎 🥜🌿
Collection
Map
Iterable
List
Queue
Set
HashMap
HashSet
ArrayList
LinkedList
...
has
Map<String, Instructor>
Map<K, V>
values: instructor objects
keys: names
Map<String, Instructor> instructors;
instructors = new HashMap<String, Instructor>();
instructors.put("Felix", new Instructor());
instructors.put("Steve", new Instructor());
instructors.put("Meghan", new Instructor());
Instructor felix = instructors.get("Felix");
Instructor steve = instructors.get("Steve");
Instructor meghan = instructors.get("Meghan");
"Felix"
"Steve"
"Meghan"
Also preserves order.
HashSet
ArrayList
LinkedList
HashMap
public class Section {
private Collection<Topic> topics;
public Section(Collection<Topic> topics) {
this.topics = topics;
}
}
public class Topic {
private Text text;
private Video video;
public Topic(Text text, Video video) {
this.text = text;
this.video = video;
}
}