LinkedList Class In Java
Java LinkedList class
LinkedList class is the second implementation class of list interface. It is similiar to ArrayList class.
Java LinkedList class uses internally doubly linked list to store the elements. It provides a linked-list data structure. It acquires the AbstractList class and implements List and Deque both interfaces.
The important points about Java LinkedList are:
- Java LinkedList class store duplicate elements as like ArrayList.
- Java LinkedList class provides insertion order as like ArrayList..
- Java LinkedList class also is none synchronized as like ArrayList.
- In Java LinkedList class, manipulation is fast because no shifting needs to occur because of internally user doubly linked list.
LinkedList Class Example : -
package CollectionOperaton; import java.util.LinkedList; import java.util.List; public class LinkedListOperation { public static void main(String args[]) { // First create a LinkedList String type List<String> linkedlist = new LinkedList<String>(); // Add the elements in LinkedList linkedlist.add("Tom"); linkedlist.add("Jeery"); linkedlist.add("Ducktales"); for (String str : linkedlist) { System.out.println(str); } } }
post a comment