We use the entrySet()
method of the AbstractMap
class to get the view of the key-value pairs (mappings) contained in the abstract map.
public abstract Set<Entry<K,V>> entrySet();
The method has no parameters.
The method returns a set view of the mappings in the map.
import java.util.*;public class Main{public static void main(String[] args) {AbstractMap<String, String> abstractMap = new HashMap<>();abstractMap.put("hello-1", "Educative");abstractMap.put("hello-2", "edpresso");abstractMap.put("hello-3", "answers");System.out.println(abstractMap.entrySet());}}
put()
method.entrySet()
method and print the result.Free Resources