java - Printing a HashMap that contains of String and List of Objects -
how can print hashmap containts of string , list of objects?
hashmap<string, list<object>> map = new hashmap<string, list<object>>(); each object has name , key value need like:
stringfirst = [ firstobject 15, second object 31, thirdobject 16] stringsecond = [ fourthobject 15, fifthobject 31, sixthobject 16] public static class graph { public class edge extends graph { string edgename; int time; edge(string edgename, int time){ this.edgename = edgename; this.time = time; } public void out(){ system.out.println(this.edgename); system.out.println(this.time); } }
try out printing map:
for(map.entry<string, arraylist<edge>> e : map.entryset()){ for(edge e1 : e.getvalue()) system.out.println(e.getkey() + " = "+ e1.out()); }
Comments
Post a Comment