ambuli
asked on
Displaying contents of ConcurrentHashMap
Hi Experts,
In the following code snippet, I am trying to print the values in the map. How can I
properly iterate through the map.
Thanks
In the following code snippet, I am trying to print the values in the map. How can I
properly iterate through the map.
Thanks
ConcurrentMap m_RequestQueue = new ConcurrentHashMap< String, QueueData>();
...
...
...
public void displayQueues()
{
System.out.println("Request Queue:");
Iterator it = m_RequestQueue.keySet().iterator();
while (it.hasNext())
{
QueueData reqData = (QueueData) it.next(); // cast exception
reqData.printData();
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Map<String,String> map = new ConcurrentHashMap<String,S
for(Entry<String, String> entry: map.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
}