java - Iterate through TreeMap - Return a set of all values of the keys of the map -
i have database maps course names student id numbers. need iterate through map create set contains students in database. code have far. appreciated!!
//return set of students in school
public set<integer> allstudents() { set<map.entry<string,set<integer>>> entries = database.entryset(); set<integer> students = new treeset<integer>(); (map.entry<string,set<integer>> pair: entries){ students.add(); } return students; } // end allstudents
you do:
for (map.entry<string, set<integer>> pair : entries) { students.addall(pair.getvalue()); }
Comments
Post a Comment