Difference between ArrayList and LinkedList in Java - the whys for performance
问题 I thought I understood the difference between ArrayList and LinkedList theoretically pretty well. However, its the first time, I put it to a little test, and the tests came out, well different to my expectations. Expectations : Arraylist will be slower than LinkedList when inserting at the beginning, since it has to "shift" the elements, for linkedlist, its just updating 2 references. Reality : came out to be same on most iterations. For a select few iterations, it was slower. Arraylist will