LinkedList or List ?

i want to store some objects into a list.which one should be used ?LinkedList or List ?where do i use LinkedList in java ? can you give an example ?
[176 byte] By [variablea] at [2007-10-2 5:48:31]
# 1
This is - no pun intended - really a stupid question.Or maybe you could post the code that raised the issue ?
da.futta at 2007-7-16 1:58:02 > top of Java-index,Java Essentials,Java Programming...
# 2
where do i use LinkedList in java ? i need explanation. not the code.
variablea at 2007-7-16 1:58:02 > top of Java-index,Java Essentials,Java Programming...
# 3
tell me an example or scenario whereLinkedList is used in java
variablea at 2007-7-16 1:58:02 > top of Java-index,Java Essentials,Java Programming...
# 4

You use LinkedList if you want to store a list of objects, and if LinkedList is preferable to other List implementations (such as ArrayList) in the context of your particular requirements. You will find that sort of thing covered in the Collections tutorial:

http://java.sun.com/docs/books/tutorial/collections/

DrClapa at 2007-7-16 1:58:02 > top of Java-index,Java Essentials,Java Programming...
# 5

You don't use LinkedList or List. List is an interface that is not instantiable, LinkedList is a concrete implementation of that interface. You use a List, regardless of implementation, when you need the functionality of a [url=http://java.sun.com/j2se/1.5.0/docs/api/java/util/List.html]List[/url].

As to whether or not using a LinkedList or ArrayList or some other implementation is most appropriate for your requirements, see the Collections information that was linked to earlier.

Also note that in general a good programming practice is to define by an interface. Thus it will not be uncommon, and is almost always preferable, to see type defined as a List rather than a specific implementation of List.

kablaira at 2007-7-16 1:58:02 > top of Java-index,Java Essentials,Java Programming...