Hi Folks,
Which collection interface is efficient to implement the singly and doubly linked list in java? code sample please?
Hi Folks,
Which collection interface is efficient to implement the singly and doubly linked list in java? code sample please?
Please check this out . http://leepoint.net/notes-java/data/collections/lists/simple-linked-list.html
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.