Sunday, October 28, 2018

hashmap - Printing a java map Map - How?

How to I print information from a map that has the object as the value?




I have created the following map:



Map objectSet = new HashMap<>();


The object has its own class with its own instance variables



I have already populated the above map with data.




I have created a printMap method, but I can only seem to print the Keys of the map



How to do I get the map to print the values using a for each loop?



So far, I've got:



for (String keys : objectSet.keySet())
{
System.out.println(keys);
}



The above prints out the keys. I want to be able to print out the object variables too.

No comments:

Post a Comment

plot explanation - Why did Peaches&#39; mom hang on the tree? - Movies &amp; TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...