When to use ArrayList ,LinkedList,Vector?


Consider a list collection. Now lets consider some scenario:

1) the list needs to be modify such that the elements are added only at the end of list, and if required only the last element of the list to be deleted, use ArrayList

2) the list needs to be modify such that the elements can be added at any position of the list, and if required the element can be deleted from any position, use LinkedList

3) the list needs to be threadsafe, use Vector.

4) the list is read only and needs to be iterated frequently, use ArrayList

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s