[Raghavan Muthu]: To answer in short, when you want to deal with heterogeneous elements in one container, that's why Collections are there
Nonsense. Collections are there to deal with groups of elements, either heterogeneous or homogeneous. I would argue that they're much more effective at dealing with homogeneous elements. Sure, it's possible to create heterogeneous collections. But why? It's certainly possible to to create homogeneous collections as well:
To consider the original question:
ArrayList is generally what you should use in most cases when you want some sort of collection.
LinkedList is a good alternative if you are frequently inserting or deleting from the beginning of the list, or from the middle (using an iterator).
Vector is used only by unwashed savages. Books that recommend Vector should be simply ignored - they are too old to be useful. Anyone who attempts to describe a Vector as "thread-safe" should be shot on sight. Seriously, these people are idiots, and should be kept as far as possible from working coders.
If you have an ancient textbook which uses the term Vector, simply pretend that they said ArrayList instead. Ignore any discussion of how Vector is "thread-safe", as the author doesn't know what he's talking about - otherwise, Vector can be easily replaced with ArrayList.
Obviously, they are here to "deal with the group of elements" precisely as the term 'Collection' literally means.
I agree that if at all you have a facility to deal with heterogeneous elements, that indeed facilitates for homogeneous elements as well. But as such, the importance of Collections were said to deal with heterogeneous elements right?
Joined: Jan 30, 2000
Sorry, but I really don't understand what you mean here. If dealing with heterogeneous elements was particularly important, an Object array did that well enough before Collections were around. Yes, Collections can deal with heterogeneous types, true, but I don't see why anyone should consider this terribly important.
subject: On what circumstances the ArrayList, LinkedList, Vector will be used.