Hi Folks,
In one of the whizzlabs exams, there is this question:
Which collection implementation is suitable for maintaining an ordered sequence of objects when objects are frequently inserted and removed from the middle of the sequence?
Please select:
a. TreeMap
b. Vector
c. ArrayList
d. LinkedList
The correct answer is 'd. LinkedList' and the explanation for the answer says:
"When objects are frequently inserted and deleted from the middle of the sequence, LinkedList gives the best performance."
I am a little puzzled by this explanation. In the Kathy Sierra book it is mentioned:
"LinkedList: Good for adding elements to the ends, i.e., stacks and queues."
Why this difference? Hope someone can help. Thanks.