Can someone explain how the following syntax works?
public static <K, V> HashMap<K, V> getMap(){
return new HashMap<K, V>();
}
As in the case where this method was implemented in an uninteresting utility class, I can use it as a static factory method to create map instances, right?
Map<Integer, String> myMap = MyUtil.getMap();
then will return a new HashMap with integer keys and String values for its records, right? If so, how are the key types and card input implemented by the compiler and VM?
I would really appreciate it if anyone could explain how Java does this.
source
share