Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Merging HashMaps

Reply
Thread Tools

Merging HashMaps

 
 
psmith@mcwy.com
Guest
Posts: n/a
 
      03-12-2007
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Merging HashMaps psmith@mcwy.com Java 3 03-13-2007 04:27 PM
HashMaps, hashcodes, equals, and Serialization Siam Java 4 12-30-2006 08:42 PM
HashCodes and HashMaps Roedy Green Java 2 09-20-2005 05:07 PM
Help on Hashmaps Marilyn Hart Java 5 01-23-2005 03:51 AM
Maps and Hashmaps neelu111@hotmail.com Java 2 05-25-2004 01:47 PM



Advertisments