If McDonalds were run like a software company, one out of every hundred Big Macs would give you food poisoning, and the response would be, ‘We’re sorry, here’s a coupon for two more.’ “ Mark Minasi


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.