Skip to content

TypeScript code snippet – How to get all the elements in Hashtable java?

// Using hashtable.keySet()

package com.java2novice.hashtable;
import java.util.Hashtable;
import java.util.Set;
public class MyHashtableKeys {
    public static void main(String a[]){
        Hashtable<String, String> hm = new Hashtable<String, String>();
        //add key-value pair to Hashtable
        hm.put("first", "FIRST INSERTED");
        hm.put("second", "SECOND INSERTED");
        hm.put("third","THIRD INSERTED");
        Set<String> keys = hm.keySet();
        for(String key: keys){
See also  Python code snippet - How to make a plt plot for na image bigger?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.