when to use ArrayList and when to use HashMap in
webApplication.

Answer Posted / naseer

When you want to retrieve use ArrayList
Dont use ArrayList if the frequent operation is insertion
and deletion instead use LinkedList.

Use HashMap if you want to store interms of Key and Value
pair .
Don’t use a HashMap unless you need the lookup feature. It
takes more time to build a HashMap than an ArrayList.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain about instanceof operator in java?

806


Explain the difference between an Interface and an Abstract class?

883


What is square root in java?

786


What are thread groups?

760


What is array and arraylist in java?

779


Explain the significance of class loaders in bootstrap?

715


What happens if an exception is not handled in a program?

850


Where will it be used?

1709


How do you sort objects in java?

742


What is Enum in Java?

900


What is method overloading in java ?

758


What are internal and external variables?

728


Explain heap sort?

910


What is a static method in java?

766


Differentiate storage classes on the basis of their scope?

880