File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
OCA Java SE 8 Programmer I Study Guide 1Z0-808
this week in the
Java in General
create a list of key/value pairs
Joined: Sep 27, 2004
Aug 12, 2011 20:59:57
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.
Joined: Mar 09, 2010
Aug 12, 2011 21:53:39
Yes. You can iterate over the map and insert them into the list.
Author and ninkuma
Joined: Jan 10, 2002
Aug 12, 2011 22:29:09
method of the Map interface should be of help.
Asking smart questions
Books by Bear
Joined: Oct 13, 2005
Aug 13, 2011 02:41:55
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.
I agree. Here's the link:
subject: create a list of key/value pairs
Convert List to a Map
Sorting Keys(Value Objects) in HashMap
Records in Arraylist
I want to check previous (value) of HashMap before adding the current key?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015