Forums Register Login

retrieve key from HashMap

+Pie Number of slices to send: Send
if I have only one remaining key/value set in a HashMap (removed all others), how can I retrieve the key



+Pie Number of slices to send: Send
I know I can print the key: mapName.keyset(), but I can't seem to assign it to a variable...
+Pie Number of slices to send: Send
I tried something that seems to work, though it looks clumsy to me, I guess I'll use it.
Sorry for posting too quickly!


+Pie Number of slices to send: Send
 

Ted Schrey wrote:I know I can print the key: mapName.keyset(), but I can't seem to assign it to a variable...



How about going through the iterator that is returned from the keyset?

Henry
This cake looks terrible, but it tastes great! Now take a bite out of this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 509 times.
Similar Threads
mapy key and null vallues
Getting all key-value pairs from a hashmap in a random order
HashMap
To extend or not to extend AbstractCollection
Which Java Collection construct will be suitable ?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 09:00:55.