0

I have a HashMap which is made up of parsed values from a textfile. Whenever I extract the contents from this HashMap, they come out in abc order. How do I keep the order that they were parsed, basically in a FIFO order.

CodeRich
  • 17
  • 4

2 Answers2

1

Use a LinkedHashMap, which can preserve insertion order.

erickson
  • 265,237
  • 58
  • 395
  • 493
1

HashMap itself is not capable of preserving the order information. Have a look at other implementations, the standard library contains LinkedHashMap for example.

Vojtech Kane
  • 559
  • 6
  • 21