I see quite often customer asking what is the right type of collection for specific purpose and performance overhead versus flexibility. This is again a passionate topic and it’s easy to get into debate with your colleagues especially during the peer code review processes.
Choosing the right Collections class must be done carefully. Using the wrong collection can unnecessarily restrict how you use it.
Consider the following questions:
Do you need temporary storage?
Do you need to access the elements in a certain order, such as first-in-first-out, last-in-first-out, or randomly?
Do you need to access each element by index?
Will each element contain just one value or a key-singlevalue pair or a key-multiplevalues combination?
Do you need to sort the elements differently from how they were entered?
Do you need fast searches and retrieval of information?
Do you need collections that accept only strings?
Hope this is useful to you when you make the choice about the collections!