问题
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