1

Is LinkedList from java.util doubly linked list? And do i need to implement my own singly linked list or there is any class for this in java.util?

Just can't find straight answers over web.

9
  • 2
    Did you check the documentation? Commented Mar 4, 2013 at 16:11
  • 1
    If it is a doubly linked list then it is also a single linked list. The problem would be the opposite. Commented Mar 4, 2013 at 16:12
  • Why do you want to know if it's singly/doubly linked? This is an implementation detail that shouldn't be important to you. Commented Mar 4, 2013 at 16:12
  • 3
    @m0skit0: I think that remark is unwarranted. LinkedList provides many operations that would have vastly different performance characteristics depending on whether it's a singly- or doubly-linked list. Commented Mar 4, 2013 at 16:13
  • 2
    @m0skit0: It's perfectly reasonable to care how the list works/performs to inform your decision of which implementation to choose. For example, you wouldn't want to use a singly-linked list implementation if you're going to be removing the last element a lot, or use a linked list at all if you're going to be doing a lot of random access. Commented Mar 4, 2013 at 16:15

1 Answer 1

4

From the LinkedList API documentation:

All of the operations perform as could be expected for a doubly-linked list.

Unless memory is an issue, a double-linked list is sufficient to meet all the needs that a single-linked list can meet.

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

2 Comments

I've seen this in doc, just wasn't 100% sure if it is what i mean't. Thanks.
It means that the observable behavior is what you would expect for a doubly-linked list -- but the implementation is encapsulated within the class, and can be anything that satisfies that specified behavior.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.