2

About the List, Linkedlist and Arraylist, which one is a one way list and which one is Doubly-linked list? And how could we reverse it?

1
  • 1
    List is interface. Are you sure you checked the API? Commented Apr 22, 2011 at 18:25

2 Answers 2

8

If you want a single-linked list, you'll have to write it yourself.

I should point out that making a single linked list that implements java.util.List is not easy. It requires you to have a ListIterator<E>, and part of the ListIterator specification is that you can traverse in either direction with methods hasPrevious, previous, and previousIndex. So to keep it both efficient and true to the single linked list mantra would be very difficult.

Sign up to request clarification or add additional context in comments.

Comments

4

You can reverse any collection using Collections.reverse(..). LinkedList (and any Deque) has descendingIterator()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.