I\'m looking for a class in java that has key-value association, but without using hashes. Here is what I\'m currently doing:
Hashtable<
LinkedHashMap will return the elements in the order they were inserted into the map when you iterate over the keySet(), entrySet() or values() of the map.
Map map = new LinkedHashMap();
map.put("id", "1");
map.put("name", "rohan");
map.put("age", "26");
for (Map.Entry entry : map.entrySet()) {
System.out.println(entry.getKey() + " = " + entry.getValue());
}
This will print the elements in the order they were put into the map:
id = 1
name = rohan
age = 26