Java, getting object from map iterator and then invoking methods? -


i have map , contains objects, lets of type 'apple'. have iterator thing seem able call getkey , getvalue. getvalue seems return memory address of actual apple object, wanted able apple = map.entry.getvalue()

i can seem key , memory address :s

iterator = applesmap.entryset().iterator();      while (it.hasnext()) {              map.entry entries = (map.entry)it.next();              system.out.println(entries.getkey() + " = " + entries.getvalue());     //apple = entries.getvalue();  }  

try way if you're using jdk 6:

for (apple apple : applesmap.values()) {     // process apple here. } 

Comments