On account of the different ways in which they implement the List interface, I understand that in theory:
ArrayList should be faster doing get() operations
LinkedList should be faster doing add() & remove() operations.
So, I thought I'd write a
test to see if that really does happen.
The program prints how long it takes for a large number of add() operations on an ArrayList and a LinkedList, allowing comparison of the two.
Similarly get() and remove().
Interestingly, as expected, for add() & remove(), LinkedList is much faster.
However, contrary to my expectation, and despite repeating the test several times, there is almost no difference as far as get() is concerned, and often ArrayList.get() seems slightly slower.
Is there something wrong with the way I'm testing get() performance, or in reality is there not much difference between the two?