As per my understanding linked list implementation in java based on double ended linked list not on Doubly linked list (as we dont have any method going backward). Though I can see the method descendingIterator which takes us backward. Not sure we should call it Doubly linked list implementation?
-
1Can you rephrase your question? I am not sure what are you asking for - what is your understanding of doubly/double(?) linked list. You even seem to have answered the question yourself.Gabriel Ščerbák– Gabriel Ščerbák2011-08-06 09:00:07 +00:00Commented Aug 6, 2011 at 9:00
-
1See: stackoverflow.com/questions/2297110/…Alberto Solano– Alberto Solano2011-08-06 10:50:22 +00:00Commented Aug 6, 2011 at 10:50
3 Answers
LinkedList actually satisfies two interfaces: the simple List and the double-linked Deque. So it can do both, depending on how you use it.
(Internally, it does keep references of previous and next element. So it is doubly linked if you want to call it like this.)
Comments
Sure, you can go forward and backward : just get a ListIterator by calling myList.listIterator(), and you'll have access to "next()" and "previous()" methods.
source : http://download.oracle.com/javase/1.4.2/docs/api/java/util/ListIterator.html
1 Comment
Yes you can do it with ListIterator interface provided by JavaSE. Using this you can go in forward and backward direction because it has function next() and previous().It has also functions to check next previous element like hasNext() and hasPrevious().It is nothing but the double-ended linked list.Hope you get it.