4/17/19

List -3 (LinkedList) | Java Collections Framework (JCF) Part -5


LinkedList has two type
- Single Linked List
- Doubly Linked List (java has doubly linkedList)

LinkedList Class
-Uses doubly linked list to store the elements
-Can contain duplicate elements
-not syncronized (It is not Thread safe)
-Maintains insertion order
-No Random access
-Manipulation fast because no  shifting needs to be occurred.


Example of LinkedList  Java Code..

import java.util.Iterator;
import java.util.LinkedList;

public class LinkedListExample {

    public static void main(String[] args) {

        LinkedList ll = new LinkedList();

        ll.add(1);
        ll.add(2);
        ll.add(3);

        ll.add(1,"Najathi");

        Iterator i = ll.iterator();

        while(i.hasNext()){
        System.out.println(i.next());}

    }

}

No comments:

Post a Comment

About

Hi, I'm Najathi.
I've started entrepreneurial company, Twin Brothers.Inc.
One is self-funded & the other is venture backed. I also send a weekly. where I share relevent, curated links.

Every Week I Publish a short post on writing, publishing, or content of IT Related

Contact Form

Name

Email *

Message *