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

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -