I know that we cannot instantiate an interface. HashMap method, keySet(), its return type is Set.
public class aMap{
public static void main(String args[]) {
HashMap newmap = new HashMap();
newmap.put(1, "please");
newmap.put(2, "help");
newmap.put(3, "me");
System.out.println("Key set values are: " +
aMap.keySet());
}
}
Output: Key set values are: [please, help, ma]
-Why can the method return a Set, which is a interface?(if Set cannot instantiate)
-Suppose Set interface can only have static final attributes and empty methods, why can it (stores) Strings into a Set?