views:

50

answers:

2

Hi Folks,

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

+2  A: 

Please check this out . http://leepoint.net/notes-java/data/collections/lists/simple-linked-list.html

Upul
+1  A: 

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.

Borealid