why people use "Map m= new HashMap()" or "List l = new ArrayList()"?



Hi,

I saw in many places that people use:

Map m= new HashMap();

or

List l = new ArrayList();

I *rarely* see people do:

HashMap m= new HashMap();

or

ArrayList l = new ArrayList();

Is any specific reason for such a practice?

I noticed Map does not have clone(), but HashMap does.
.



Relevant Pages

  • Re: synchronized HashMap vs. HashTable
    ... However, the HashTable is, supposedly, inherently thread-safe. ... Use HashMap or another ... Map utensil, not Hashtable, which is an Aryan cousin of the cheesecakes ... "Masonry conceals its secrets from all except Adepts and Sages, ...
    (comp.lang.java.programmer)
  • Re: LinkedList vs ArrayList
    ... as one or more HashMap instances. ... To insert or delete at head or tail, ... and also adjust the lowest or highest index value. ... To access by value fast, keep the reverse map, object to Integer. ...
    (comp.lang.java.programmer)
  • Re: how to iterate through a map in struts
    ... i hav a form bean LoginForm.and a getter mathod getID,which returns ... the values of a map if passed the key as parameter....my code.. ... be decalaring your HashMap as property. ... In my form bean itself i will declare the HashMap. ...
    (comp.lang.java.programmer)
  • Re: how to iterate through a map in struts
    ... i hav a form bean LoginForm.and a getter mathod getID,which returns ... the values of a map if passed the key as parameter....my code.. ... Here's an example using Struts tags. ... be decalaring your HashMap as property. ...
    (comp.lang.java.programmer)
  • Re: inheritance evil
    ... > HashMap, etc because I don't want to redefine all the interfaces. ... Inheritance should be a "is-a" relationship. ... Generally, when people want to make their own Map, they extend HashMap ... As far as the new Map implementation goes, the mapping algorithm ...
    (comp.lang.java.programmer)