entrySet(): This method is available in java.util.HashMap class of Java.
Syntax:
Set<Entry<K, V>> java.util.HashMap.entrySet()
This method returns a Set view of the mappings contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa.
Parameters: NA
Returns: a set view of the mappings contained in this map.
Exceptions: NA
Approach
Java
import java.util.HashMap;public class HashMapentrySet {public static void main(String[] args) {HashMap<String, Integer> hashMap =new HashMap<String, Integer>();hashMap.put("Hello", 1);hashMap.put("World", 2);System.out.println(hashMap.entrySet());}}
Output:
[Hello=1, World=2]
No comments:
Post a Comment