How to print the hashmap values from the order they inserted into the hashmap

Viewed 6692

I have a HashMap which have strings as key and value,

HashMap dataSet = new HashMap();

dataSet.put("A1", "Aania");
dataSet.put("X1", "Abatha");
dataSet.put("C1", "Acathan");
dataSet.put("S1", "Adreenas");

I want to print it as the order it is inserted into the HashMap, So the output should be like,

A1, Aania
X1, Abatha
C1, Acathan
S1, Adreenas  

Can anyone please tell me how to do this?

2 Answers
Related