A programmer is a person who passes as an exacting expert on the basis of being able to turn out, after innumerable punching, an infinite series of incomprehensive answers calculated with micrometric precisions from vague assumptions based on debatable figures taken from inconclusive documents and carried out on instruments of problematical accuracy by persons of dubious reliability and questionable mentality for the avowed purpose of annoying and confounding a hopelessly defenseless department that was unfortunate enough to ask for the information in the first place. Grid newsmagazine


Language Java | Level Intermediate | Category Java collections framework (JCF) | 2015-07-22 19:26:48



Linked list is a Doubly-linked list implementation. Linked list is a data structure consisting of a group of nodes which together represent a sequence which each node link with previous and next node.


Doubly-linked list implementation of the List and Deque.
Not synchronized. If the linked list accesses from multiple threads, external synchronization required.
Fail-fast of an iterator is not guaranteed.
If multiple threads access and try to update, It throws ConcurrentModificationException.

source Code

package com.careerdrill.collections.deque;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

public class LinkedListUse {
	public static void main(String[] args) {

	int []array={12,24,48,78,99};
    System.out.println("Add the elements to the linked list: "+Arrays.toString(array));
    List< Integer > ll = new LinkedList< Integer >();

    for(int i : array)

    System.out.println("Add '11' at end of the linked list");
    ((LinkedList< Integer >) ll).addLast(11);
    System.out.println("Add '9' at beginning  of the linked list");
    ((LinkedList< Integer >) ll).addFirst(9);
    ll.add(1, 22);
    System.out.println("Display all the linked list elements: " + ll);


Add the elements to the linked list: [12, 24, 48, 78, 99]
Add '11' at end of the linked list
Add '9' at beginning of the linked list
Display all the linked list elements: [9, 22, 12, 24, 48, 78, 99, 11]


linkedlist Array List
Linked list search operation is slower than array list. ArrayList search operation is pretty fast compared to the LinkedList.
LinkedList element addition and deletion is faster compared to ArrayList. Array List takes more time for inserting and deleting the elements.
LinkedList has more memory overhead than ArrayList. ArrayList has less memory overhead compared than LinkedList.
Internally uses dynamic array. Internally uses doubly linked list.
Linked list uses links and no need adjust index. ArrayList needs to adjust the indexes according to deletion or insertion.

When to use

Linked list is the best choice when the user uses already defined iterators and insert/delete the elements at beginning and end.


Please login to add comments.