S
Shikha
I need to make a collection wherein i can have a key value pair and the
sorting happens in alphabetical order of values. also i want that after
the initial insert of values if i add or remove any value then the
collection should be sorted again in alphabetical order.
- i cant use arraylist because it doesnt have a key value pair.
- i cant use a hashmap because when i iterate the values i get them in
a random order whereas i want them in alphabetical order.
- TreeMap does the sorting in order of keys.
- LinkedHashMap does the sorting in order of insertion. so for the
initial insert it will be fine
but when i add and remove values it will not give me the alphabetical
order.
would appreciate some help on this
thanks
shikha
sorting happens in alphabetical order of values. also i want that after
the initial insert of values if i add or remove any value then the
collection should be sorted again in alphabetical order.
- i cant use arraylist because it doesnt have a key value pair.
- i cant use a hashmap because when i iterate the values i get them in
a random order whereas i want them in alphabetical order.
- TreeMap does the sorting in order of keys.
- LinkedHashMap does the sorting in order of insertion. so for the
initial insert it will be fine
but when i add and remove values it will not give me the alphabetical
order.
would appreciate some help on this
thanks
shikha