Hashtable entrySet() in Java

entrySet(): This method is available in java.util.Hashtable class of Java.

Syntax:

Set<Entry<K, V>> java.util.Hashtable.entrySet()

This method returns a Set view of the mappings contained in this map.

Parameters: NA

Returns: a set view of the mappings contained in this map.

Exceptions: NA

Approach

Java

import java.util.Hashtable;

public class HashtableentrySet {
    public static void main(String[] args) {
        Hashtable<String, Integer> hashtable =
new Hashtable<String, Integer>();

        hashtable.put("Hello", 1);
        hashtable.put("World", 2);

        System.out.println(hashtable.entrySet());

    }
}

Output:

[World=2, Hello=1]


No comments:

Post a Comment