If the concrete instance of your Map
object is a LinkedHashMap
yes. It does not matter what you do with it. The object will keep it's data ordered and the implementation does not change if you cast to just Map
or even Object
or pass it to methods. It will stay internally a LinkedHashMap
. You might no longer see that it is one if you cast it to Object
.
Assuming that you don't know the source code, the only thing that is not guaranteed is that someOtherMethod
returns your LinkedHashMap
. It could also re-order it.
A method should not be trusted unless it specifies those things. But since you know the sourcecode here, you have the guarantee that it is your LinkedHashMap
in perferct order.