when we go for HashMap and ArrayList in realtime with code snippet especially in web applications

Discussion in 'Strings, I/O, Formatting, Parsing' started by dileepkumar_06, Sep 2, 2010.

  1. dileepkumar_06

    dileepkumar_06 New Member

    Can any one tell me when we use ArrayList and when we use HashMap, and in which case we will use these in the real time especially in web applications?? can any of the guys let me know immediately with code snippet.
     
    Last edited: Sep 2, 2010
  2. nagendra_gang

    nagendra_gang New Member

    It is depends on the situation some time it is recommended to use HashMap When u want to store your data in the form of Key->Value pair just like the Session,request,response objects in which you store data like name of the user as name->(name of the use).It is also recommended to use HashMap when you have to achieve high accessing(searching) speed (Just overload hashcode method properly to achieve high speed)

    And when you want to store the object in an order (order of insertion) use ArrayList,It does not store key for object it just stores the object and you have to use index of that object to access it.Duplicate value also allows

    with regard
     

Share This Page