• Dear Guest, Please do NOT forget to join our JAVA JOBS (ONLY) FACEBOOK GROUP to be aware of latest JAVA openings, and you may also post any JAVA related queries/jobs.

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

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:
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