Linked list implementation in java?
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 meth开发者_运维知识库od descendingIterator which takes us backward. Not sure we should call it Doubly linked list implementation?
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.)
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
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.
精彩评论