| Author |
create a list of key/value pairs
|
JayaSiji Gopal
Ranch Hand
Joined: Sep 27, 2004
Posts: 303
|
|
I am not sure if the following is doable:
I have say a hashmap - key:"1" value: "one".
I want to convert this hashmap to a list - ["1":"one"]
Is this doable?
|
SCJP 1.4, SCWCD 1.4<br /> <br />Thanks in advance!<br />Jayashree.
|
 |
bhanu chowdary
Ranch Hand
Joined: Mar 09, 2010
Posts: 256
|
|
|
Yes. You can iterate over the map and insert them into the list.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56185
|
|
|
The entrySet() method of the Map interface should be of help.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32654
|
|
|
Do you really want a List? There is no particular order to the entries in a Map. You can use a hybrid list and Map of you wish to introduce an ordering.
|
 |
 |
|
|
subject: create a list of key/value pairs
|
|
|