How to Maintain order of insertion using collections

Posted by sarah on Stack Overflow See other posts from Stack Overflow or by sarah
Published on 2010-06-04T11:44:25Z Indexed on 2010/06/05 14:42 UTC
Read the original article Hit count: 159

Filed under:
|
|
|

I want to add a key,value pair into a hashtable (or any other collection) but have to maintain insertion order. How can I do this?

Like I'll add 1 as key "one" as value, 2 as key and "two" as value.

The output should be ordered as:

1:one
2:two

© Stack Overflow or respective owner

Related posts about java

Related posts about collections