Home > Back-end >  Consult a HashMap <String, the String> and Map <String, the String> what's the diff
Consult a HashMap <String, the String> and Map <String, the String> what's the diff

Time:05-16

Consult the following what is the difference between two kinds of definition?
Which performance is good? Thank you
The static HashMap Hash_org1=new HashMap (a);
The static Map Hash_org1=new HashMap (a);

CodePudding user response:

Performance difference, because is a reference point to is a hashmap instance
But consider from the extensibility, the second is better, because the map is the interface, can according to demand changes to different instances of the map, and the first kind is bound to be pointing to a hashmap (because types have identified only a hashmap)
  • Related