简体   繁体   中英

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 method 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.

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