Java: How to call a method from class from an enumeration of instanced objects? -



Java: How to call a method from class from an enumeration of instanced objects? -

i made several instances of objects in hashtable , want phone call method each of them.

i made goes through enumeration of values retrieved said hashtable, i'm unsure how phone call method on each object.

for(enumeration<agent> agentenum = agentlist.elements(); agentenum.hasmoreelements();){ //content+= agentenum.nextelement(); }

content should receive homecoming of method i'm trying phone call class agent.

iterate on keys in hashmap. example:

enumeration<agent> agentenum = agentlist.keys(); while(agentenum.hasmoreelements()) { agent key = agentenum.nextelement(); your_class value = agentlist.get(key); value.whatever(); ... }

edit

or utilize values directly:

for(your_class obj : agentlist.values()) { obj.whatever(); ... }

other methods discussed here, example.

java

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -