singly and doubly linked list in java?

早过忘川 提交于 2020-06-23 11:54:46

问题


Which collection interface is efficient to implement the singly and doubly linked list in java? code sample please?


回答1:


The right interface to implement a doubly-linked list is, unsurprisingly, a LinkedList. See the JavaDoc.

I'm not going to give you a code sample here; they're all over the web and you could find one with two minutes' research.

If you want a singly-linked list for some reason, you're probably going to have to roll your own using a custom Node class. Each Node should just have a data object and a pointer to the next Node.



来源:https://stackoverflow.com/questions/3393254/singly-and-doubly-linked-list-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!