Originally posted by dhanya kairali:
Is there any workaround for not having the TreeMap sort the contents. (leave the contents as it was originally added to it)
I do not have a choice of using a Map that doesnt sort - I need a TreeMap cos thats what a method thats outside my control expects.
Dhanya
That looks like bad design - If the method accepted any Map, you could pass it a LinkedHashMap which maintains the insert order.
If you really must use a TreeMap, you could subclass TreeMap and make it do what you want it to do. But that would be even worse, because you are breaking the contract declared by TreeMap, which is to maintain keys in the sorted order.