Hashmap to Array
in
Programming Questions
•
2 years ago
I would like to use a hashmap to browse through a 2D array. Here is a simplified version of what I'm looking for.
HashMap hm = new HashMap;
hm.put ("Pinus", "Tree");
hm.put ("Juniper, "Tree");
hm.put ("Spore", "Herb");
hm.put ("Grass", "Weed");
hm.put ("Alge", "Marine");
hm.put ("Oak", "Tree");
hm.put ("Dandelion", "Weed");
Is there a way to get all the keys associated with Tree into some sort of array? So, Tree = Pinus, Juniper, Oak. I read up on hashmaps, but don't truly understand how to fully use them. Thank you.
1