aspose file tools*
The moose likes Java in General and the fly likes Any Class which provides key-value pair in same order Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Any Class which provides key-value pair in same order" Watch "Any Class which provides key-value pair in same order" New topic
Author

Any Class which provides key-value pair in same order

pavan in
Ranch Hand

Joined: Oct 22, 2002
Posts: 64
Does java has any Class which provides (get) key-value pair in same order as it was (when add).
say,
if I add ("1","A"), ("2","B"), ("3", "C").
when I get, I should get values A - B - C.
I am using jdk1.3.1 (using Weblogic 7.0 which supports only jdk1.3)
Thanks.
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 986

Not that I know of, but you can cheat by keeping a copy of the 'keys' in a separate data structure.


Please ignore post, I have no idea what I am talking about.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
JDK 1.4 offers the LinkedHashMap which sounds like exactly what you want. If you can't switch to 1.4 you could study the source code for LinkedHashMap to create a version for 1.3.


"I'm not back." - Bill Harding, Twister
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Any Class which provides key-value pair in same order