简体   繁体   中英

singly and doubly linked list in java?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM