Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialdlpuxdzztg
8,243 PointsChallenge 2 confusion...
Hello,
I'm doing challenge 2 for this video, and i'm stuck on what to do from here:
public Set<String> getAvailableContactMethods() {
// FIXME: This should return the current contact method names.
Set<String> avaliableContactMethods = new HashSet<String>();
return avaliableContactMethods;
}
I'm not sure how you are suppose to return the current contact method names...if 'methodName' is a 'getContactInfo' parameter.
Thanks!
1 Answer
Kourosh Raeen
23,733 PointsHi Diego - The HashMap class has the keySet()
method that returns a set of all the keys. Call that method on mContactMethods
and return the result.
dlpuxdzztg
8,243 Pointsdlpuxdzztg
8,243 PointsThanks!
Also, just curious, was 'keySet()' covered before?
Kourosh Raeen
23,733 PointsKourosh Raeen
23,733 PointsYou're welcome. Yes,
keySet()
was covered in the Maps video at 05:07.dlpuxdzztg
8,243 Pointsdlpuxdzztg
8,243 PointsAh, okay.
I hope you don't mind, but could you also help me a little with challenge 3? Here is my code so far:
Kourosh Raeen
23,733 PointsKourosh Raeen
23,733 PointsFor part 3 you need to return a single value for the passed in key
methodName
, so there is no need for a loop or a HashSet. You just need one line of code that uses HashMaps'sget()
method to return the value associated with the keymethodName
.dlpuxdzztg
8,243 Pointsdlpuxdzztg
8,243 PointsThanks!