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
  • 257,800
  • 54
  • 385
  • 479
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
  • 529
  • 5
  • 17