Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is it possible to access to java.util.LinkedList node directly?

Is it possible to access to java.util.LinkedList node directly, and manually swap two nodes by change next and prev links?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

No. The node is not publicly accessible, and it’s an implementation detail that may change or even disappear in a given Java runtime.

Yes. With sufficient effort and ongoing care, you can use reflection to manipulate the normally inaccessible innards of a particular implementation.

I suspect this might be an XY problem, and if you described your goal, it might be that a different collection would work better.


For an LRU cache, you could use LinkedHashMap, with the access-order flag set.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading