inheritance - Declaring a superclass variable then instantiating it with a subclass in Java -


this question has answer here:

i little confused , looking clarification on differences , different benefits 2 different approaches declaration , instantiation of map.

what difference between

map<string, string> mymap = new hashmap<string, string>; 

and

hashmap<string, string> mymap = new hashmap<string, string>; 

what benefit or reason declaring superclass variable instantiating subclass?

this called "programming interface". (map interface, not class.) allows code needs map operations not care kind of map is.

you switch out hashmap for, say, treemap if feel it's appropriate, , no other code change.

other similar questions:

other references:


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -