Does Colelction.unmodifiableMap safeguard the iteration order?
I was trying newMap.put(key,Collections.ModifiableMap(oldMap)) Then when I do newMap.get(key) and iterate, iterate order seems to change.
How can we protect the iterate order?
UnmodifiableMap simply delegates all methods, except writing ones. It's order is exactly that of the delegate.
If you need to have the same order as the first collection, use LinkedHashMap.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With