32a-section-5-solutions

32a-section-5-solutions - CS 106A Handout #32A July 30,...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Handout #32A CS 106A July 30, 2009 Solution to Section #5 1. Using Maps Keeping track of email addresses We’ll use a map to relate people’s names with their email address: Map<String, String> Maintaining Facebook profiles We could have a map that relates people’s names with a profile description: Map<String, String> If profiles turns out to be more complex (which they probably are, because the average profile keeps track of not only a small description, but other things, like birthdays, jobs, networks, etc.), we could make a Profile object, and map names to Profile objects. Map<String, Profile> (We might cover creating your own classes/objects in the coming lectures…) Holding students’ study lists This one is a little tricky… we need to relate an individual with a whole bunch of classes. The solution is to “compound” our data structures… we can map a student’s name ( String ) to a list ( ArrayList ) of classes ( Strings ). Map<String, ArrayList<String> >
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

32a-section-5-solutions - CS 106A Handout #32A July 30,...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online