The keyset()
method of the AbstractMap
class is used to get the set view of the keys in the abstract map.
public Set<K> keySet()
The method has no parameters.
The method returns a set view of the keys 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.keySet());}}
put()
method.keySet()
method and print them.Free Resources