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 trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Rob Siepkowski](https://secure.gravatar.com/avatar/926110cb38c3169ef7667a83d545689f?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Rob Siepkowski
7,641 PointsJava "get" method on a Map. Question from Quiz
/*** This is a quiz question. It is asking us to fill in blank below to retrieve Ravi's grade. I have tried a dozen different variations of studentGradeMap.get() with random spellings and variations of ravi and student and quotes and parens and everything I can think of and nothing is working. please help!! Thank you! ***/
Fill in the blank to retrieve Ravi's Grade from the Map:
import java.util.HashMap; import java.util.Map;
public class Main {
public static void main(String[] args) {
Student ravi = new Student();
Student sid = new Student();
Student grace = new Student();
Grade A = new Grade();
Grade B = new Grade();
Grade C = new Grade();
Grade D = new Grade();
Map<Student, Grade> studentGradeMap = new HashMap<>();
studentGradeMap.put(ravi, B);
studentGradeMap.put(sid, C);
studentGradeMap.put(grace, B);
Grade ravisGrade = // ????? fill in blank here ??????
}
}
class Student { // omitted }
class Grade { // omitted }
4 Answers
![KRIS NIKOLAISEN](https://secure.gravatar.com/avatar/65d74a723997b41a80d2d909c6e06960?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
KRIS NIKOLAISEN
54,969 PointsHave you tried
studentGradeMap.get(ravi)
?
![Anas Ahmad](https://uploads.teamtreehouse.com/production/profile-photos/10738419/micro_profile.jpg)
Anas Ahmad
432 PointsHi there.I was facing the same issue but you already asked the same question thank you so much.
![Ben Basty](https://uploads.teamtreehouse.com/production/profile-photos/9866322/micro_profilepic.jpg)
Ben Basty
23,772 PointsstudentGradeMap.get(ravi)
![Denson Dube](https://secure.gravatar.com/avatar/1db7b76d527a15586c34830f1d9bc79d?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Denson Dube
2,615 PointsMap <Student,Grade> studentGradeMap = new HashMap<>();
Rob Siepkowski
7,641 PointsRob Siepkowski
7,641 PointsThanks Kris! Much appreciated!!
I thought I had already tried that.
I had tried the exact same thing you wrote, but I was putting ravi in quotes ... "ravi". That's where i was going wrong.
Your answer works perfectly!
Thanks so much!