iterating through hash table in order code example
Example: iterate through hashtable java
//create hash table
HashTable<String , int> ht = new HashTable<>();
ht.put("first",1);
ht.put("second",2);
//create a set holding all keys in the hashtable
Set<String> keys = ht.keySet();
//iterate through with a for loop
for(String key : keys) {
System.out.println(ht.get(key));
}
//OUTPUT
// 1
// 2