keySet(): This method is available in java.util.Hashtable class of Java.
Syntax:
Set<K> java.util.Hashtable.keySet()
This method returns a Set view of the keys contained in this map.
Parameters: NA
Returns: a set view of the keys contained in this map.
Exceptions: NA
Approach
Java
import java.util.Hashtable;public class HashtablekeySet {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.keySet());}}
Output:
[World, Hello]
No comments:
Post a Comment