Merging HashMaps

P

psmith

I have to merge two hashmaps, one results (contains grades), the other
students(contains students, with exam results. Their exam marks are
averaged out and graded. I need the students to appear in the results
hashmap against their grade, can somebody please point out what is
wrong with the following:

public void collateResults()
{
char grades[] = {'A', 'B', 'C', 'D', 'F', 'X'};
{
for (Character grade : grades)
{
this.results.put(grade, new HashSet<String>());
}
for (String eachStudent : students.keySet())
{
for(String graded : this.results.get(eachStudent))
{
this.results.get(graded).add(eachStudent);
}
}
}
}

Any help greatly appreciated.

Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top