singly and doubly linked list in java?

前端 未结 1 509
旧巷少年郎
旧巷少年郎 2021-01-24 15:53

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

相关标签:
1条回答
  • 2021-01-24 16:17

    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.

    0 讨论(0)
提交回复
热议问题