| Author |
How to rearrange the elements in LinkedHashMap?
|
vicky saxena
Greenhorn
Joined: Aug 23, 2005
Posts: 15
|
|
How Can I rearrange elements in LinkedHashMap i.e the shuffling of elements can I insert the elements in between the LinkedHashMap
|
 |
Scott Selikoff
Saloon Keeper
Joined: Oct 23, 2005
Posts: 3652
|
|
|
I don't believe you can, as LinkedHashMap only maintains insertion order and does have any methods for inserting between elements. You should either use a different collections class, or rebuild the LinkedHashMap (can be expensive if this is frequent).
|
My Blog: Down Home Country Coding with Scott Selikoff
|
 |
Roger Chung-Wee
Ranch Hand
Joined: Sep 29, 2002
Posts: 1683
|
|
|
Try an implementation of SortedMap such as TreeMap. You can control the ordering by having each object in the map implement the Comparable interface.
|
SCJP 1.4, SCWCD 1.3, SCBCD 1.3
|
 |
 |
|
|
subject: How to rearrange the elements in LinkedHashMap?
|
|
|