79595353

Date: 2025-04-27 18:35:41
Score: 0.5
Natty:
Report link

In general you are right.
LinkedList is only in theory faster. Especially in Java, LinkedList has a memory overhead because of the 2 pointers (it is actually a double linkedlist). So the memory usage is worse and in practice degrades the performance.
ArrayList is almost always (there are only very few edge cases) faster and more efficient than LinkedList and also ArrayDeque. And you are right, for these Edge Cases, ArrayDeque is the better choice.
As a Bonus Point: ArrayList is backed by a single continguous array in memory. The CPUs are much faster in accessing sequential memory. The hotspot optimizations (the JIT compiler) are working better with the array like memory layouts.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (0.5):
Posted by: Mr__Steel