Eugene Eugene - 1 year ago 61
Java Question

Is it possible to get element from HashMap by its position?

How to retrieve an element from HashMap by its position, is it possible at all?

Answer Source

HashMaps do not preserve ordering:

This class makes no guarantees as to the order of the map; in particular, it does not guarantee that the order will remain constant over time.

Take a look at LinkedHashMap, which guarantees a predictable iteration order.