LinkedList extends AbstractSequentialList and implements List interface, Cloneable, Serializable.
Java Collections Framework- LinkedList Class
LinkedList extends AbstractSequentialList and implements List interface,
Cloneable, Serializable. It provides a linked-list data structure. The LinkedList
is not synchronized. It permits all elements including null. In addition to implementing the List interface, the LinkedList class provides
uniformly named methods to get, remove and insert an element at the beginning and end of the list. These operations
allow linked lists to be used as a stack, queue, or double-ended queue.
All of the operations perform as could be expected for a doubly-linked list. Operations that index into the list will traverse the list from the beginning
or the end, whichever is closer to the specified index.
LinkedList has the constructors shown here:
- LinkedList( ) - Constructs an empty LinkedList.
- LinkedList(Collection c) - Constructs a Linked List containing the elements of the specified collection, in the order they are returned by the collection's iterator.
The following program shows a simple use of LinkedList
package devmanuals.com; import java.util.*; public class LinkedListDemo { public static void main(String[] args) { LinkedList LKLST = new LinkedList(); LKLST.add("Gyan"); LKLST.add("Singh"); LKLST.add("Arunesh"); LKLST.add("Kumar"); System.out.println("The LinkedList Elements are : " + LKLST); } }
Output:
The LinkedList Elements are : [Gyan, Singh, Arunesh, Kumar] |
Here is the more examples of LinkedList class methods implementation.
[ 0 ] Comments