Some JDK APIs are obsolete and have preferred alternatives.
LinkedList almost never out-performs
If you are using
LinkedList as a list, prefer
ArrayList. If you are using
LinkedList as a stack or queue/deque, prefer
Vector performs synchronization that is usually unnecessary; prefer
If a synchronized collection is necessary, use
a data structure from
This is a nonstandard class that predates the Java Collections Framework; prefer
If synchronization is necessary,
usually a good choice.
Stack is a nonstandard class that predates the Java Collections Framework;
If a synchronized collection is necessary, use a data structure from
StringBuffer performs synchronization that is rarely necessary and has
significant performance overhead. Prefer
StringBuilder, which does not do
If synchronization is necessary, consider creating an explicit lock object and
An ancient precursor to
NavigableMap in Java 6.
LinkedList has slow traversal, and typically you need to
traverse the list to find the place to insert/remove. It turns out that
the cost of traversing to a location in a
LinkedList is approximately 4x
the cost of copying an element in an
traversal cost dominates and results in poorer performance.
More info: https://stuartmarks.wordpress.com/2015/12/18/some-java-list-benchmarks/
Suppress false positives by adding an
@SuppressWarnings("JdkObsolete") annotation to the enclosing element.
People generally choose
LinkedList because they want fast insertion and ↩