Quick revision
The short answer
LinkedList persists because once an API is public and widely used, the platform keeps it for compatibility, even when a better option such as ArrayList or ArrayDeque exists. The realistic way to steer usage is guidance and tooling rather than removal. In our own libraries, we keep the public surface small, add better alternatives before deprecating old ones with clear reasons, and use static analysis to point teams to the preferred types.
What to remember
In this answer, we saw that LinkedList survives because public APIs become long commitments under Java's compatibility promise, and the JDK steers usage with documentation and staged deprecation rather than removal. In our own libraries, we keep the public surface small and interface-based, add better alternatives before deprecating old types with clear reasons, and use static analysis and automated migration to move teams, spending effort where measurements show a cost.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
LinkedList persists because once an API is public and widely used, the platform keeps it for compatibility, even when a better option such as ArrayList or ArrayDeque exists. The realistic way to steer usage is guidance and tooling rather than removal. In our own libraries, we keep the public surface small, add better alternatives before deprecating old ones with clear reasons, and use static analysis to point teams to the preferred types.
Why this question is asked
Every long-lived codebase carries choices that were reasonable once and are poor now. The JDK is the most visible example, with LinkedList, Vector, Hashtable and Stack all still shipping. Interviewers ask this question to see how a senior engineer thinks about API lifetimes: what it really costs to publish an interface, why removal is so hard, and how to move many teams to better choices without breaking them. In this answer, we will look at why such APIs survive, what that teaches about publishing APIs, and then walk through how we would retire a legacy choice in our own shared libraries, with an example.
1Why the JDK Keeps APIs It Would Not Design Today
Java's strongest promise is backward compatibility: code compiled years ago keeps running on new JDKs. LinkedList is part of the public collections API, it appears in method signatures across thousands of libraries, and it is not wrong, only usually slower. Removing it would break those libraries and every application that depends on them, for a gain that guidance can deliver almost as well.
So the JDK removes things only when keeping them is harmful, such as security-sensitive or unmaintainable APIs, and even then it goes through stages: deprecation, deprecation marked forRemoval, warnings for several releases, and only then removal. Classes like Vector and Hashtable were never removed; they were superseded, and the documentation points to better types. LinkedList even gained new methods when Java 21 added sequenced collections, because a type in the API has to keep up with the rest of the API.
2The Lesson: Every Public API Is a Long Commitment
The cost of an API is not the effort to write it but the years of supporting it. Once a type or method is public and used, its behaviour becomes a contract, including behaviour nobody intended, such as allowing nulls or iterating in a certain order. People build on all of it.
This leads to a practical rule: keep the public surface small. Expose interfaces such as List rather than concrete classes in signatures, so the implementation can change. Keep helpers package-private until someone needs them. Add a public method only when we are ready to support it for as long as the library lives. A small surface is cheap to maintain and cheap to evolve, while a large one freezes design choices in place.
3Retiring a Legacy Choice in Our Own Library
Suppose our shared library exposes OrderQueue extends LinkedList<Order>, created years ago, and many services use it. Profiles show the node allocation costs, and we want teams on an ArrayDeque-based design. A senior engineer does not delete the class. We add the alternative first, so there is somewhere to go, then deprecate the old type with the reason and the replacement, give teams time and help, and remove it only in a major version if at all.
- Add the better alternativesmall surface, documented
- Deprecate with reason and replacement
@Deprecated(since, forRemoval) - Add toolingstatic analysis rule, migration recipe
- Track usagecount call sites per release
- Is usage near zero?YesRemove in a major versionNoKeep supporting, help the remaining teams
5 steps in order. Play them, or step through them one at a time.
Notice that the new type does not extend ArrayDeque. It wraps it and exposes three methods. That is the lesson from LinkedList applied: if OrderBuffer exposed every Deque method, we would be committed to all of them forever. And the deprecation message says why, not only what, because teams prioritise changes they understand.
4Steering Teams With Tooling Instead of Rules Alone
Documents asking people to avoid LinkedList are read once and forgotten. Tooling works at the moment of writing code. Static analysis tools can flag obsolete JDK types; Error Prone, for example, has a check for JDK types with better modern alternatives (check the exact check name and behaviour for your version), and teams can add their own rules with ArchUnit or a custom lint. We start such a rule as a warning on new code only, so it does not block builds with hundreds of old findings, and raise it to an error once the count is low.
Automated migration helps the rest. A refactoring recipe, for example with OpenRewrite, can change simple cases such as new LinkedList<>() used as a local List into new ArrayList<>() across many repositories, leaving only the unusual ones for people to review. We track the remaining count per release and publish it, which turns a vague preference into visible progress.
Finally, we keep perspective. A LinkedList holding twenty items in a configuration class costs nothing worth a migration. We spend the effort where profiles show a cost, or where the type leaks into public signatures that we will otherwise support for a decade.
5Follow-up questions
Why not just remove LinkedList from our own code base in one big change?
Because a single huge change across many teams is risky to review and hard to roll back, and most uses cost nothing measurable. Fixing new code through tooling, migrating hot paths that profiles point to, and letting the rest change naturally gives most of the benefit at a fraction of the risk.
What does forRemoval = true add over a plain @Deprecated?
It tells users that the API is actually going away, not only discouraged. Compilers report it with a stronger, separate warning that is on by default, so teams see it even if they ignore ordinary deprecation warnings. It is a signal to plan migration now.
How long should a deprecated API stay before removal?
Long enough for every consumer to move during normal work, which in practice means at least one or two release cycles of the library and a major version for the removal itself. For widely used internal libraries, we decide by usage data, not by a calendar: remove when the call-site count is zero or close to it.
6Conclusion
In this answer, we saw that LinkedList survives because public APIs become long commitments under Java's compatibility promise, and the JDK steers usage with documentation and staged deprecation rather than removal. In our own libraries, we keep the public surface small and interface-based, add better alternatives before deprecating old types with clear reasons, and use static analysis and automated migration to move teams, spending effort where measurements show a cost.
Open with
LinkedList is rarely the best choice, but it stays in the JDK because Java promises backward compatibility, and LinkedList is in signatures across thousands of libraries. It is not broken, just usually slower than ArrayList or ArrayDeque, so removing it would break far more than it helps.
Then, if they want more
The JDK steers people with documentation and, where something is harmful, staged deprecation, rather than removal. Vector and Hashtable are the same story. The lesson I take is that a public API is a commitment for as long as the library lives, including behaviour nobody intended.
So in my libraries I keep the public surface small, I expose interfaces like List rather than concrete classes, and I keep helpers package-private until there is a real need. When I want to retire a legacy choice, I first add the better alternative, for example a small OrderBuffer type wrapping ArrayDeque instead of a class extending LinkedList.
Then I deprecate the old one with since and forRemoval, and the message explains why and what to use. I add tooling, such as an Error Prone or ArchUnit rule as a warning on new code, and an automated migration recipe for simple cases, and I track the remaining call sites per release.
I remove only in a major version once usage is near zero, and I do not spend effort on uses that profiles show cost nothing.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Java 21
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- The Collections Framework, overview, java.util, package documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "LinkedList is rarely the best choice in modern Java, yet it remains in many codebases...": https://scrivio-interview-library.netlify.app/java/lists/15ee45f2c4/