Does the HashMap preserve the order of its elements in the next reading if it is constructed and "populated" like a LinkedHashMap?
Suppose I have a Java method that returns a HashMap object.
Since LinkedHashMap is a subclass of HashMap, I can return LinkedHashMap from this method just fine.
On the next read action (without adding / removing / modifying the K / V pairs), iterating over the keys of the resulting method (which returns the HashMap) will go in the same order as the original LinkedHashMap, even though the HashMap is missing key references?
+2
a source to share