Answers for "iterate through hash table"

0

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
Posted by: Guest on June-16-2020

Code answers related to "iterate through hash table"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language