Saturday, April 20, 2019

Linkedlist Java

Key facts about Linkedlist
·  LinkedList can have duplicate and null values.·  The LinkedList class implements Queue and Deque interfaces. Therefore, It can also be used as a QueueDeque or Stack.
·  Java LinkedList is not thread-safe. You must explicitly synchronize concurrent modifications to the LinkedList in a multi-threaded environment.·  Java LinkedList maintains the insertion order of the elements.

Linkedlist Example:import java.util.*;
public class LinkedListExample {
     public static void main(String args[]) {
       /* Linked List Declaration */
       LinkedList<String> testlist = new LinkedList<String>();
       /*add(String Element) is used for adding 
        * the elements to the linked list*/
       /*Display Linked List Content*/
       System.out.println("Linked List Content: " + testlist);
       /*Add First and Last Element*/
       testlist.addFirst("First Item");
       testlist.addLast("Last Item");
       System.out.println("LinkedList Content after addition: " + testlist);
       /*This is how to get and set Values*/
       Object firstvar = testlist.get(0);
       System.out.println("First element: " +firstvar);
       testlist.set(0, "Changed first item");
       Object firstvar2 = testlist.get(0);
       System.out.println("First element after update by set method: " +firstvar2);
       /*Remove first and last element*/
       System.out.println("LinkedList after deletion of first and last element: " + testlist);
       /* Add to a Position and remove from a position*/
       testlist.add(0, "Newly added item");
       System.out.println("Final Content: " + testlist); 
       /* Access specific element in the Linkedlist*/
       testlist.indexOf(“Newly added item”);

       /*Iterator for Linkedlist*/
       Iterator<String> testlistIterator = testlist.iterator();
        while (testlistIterator.hasNext()) {
            String speciesName =;

Applications of linked list in real world-
  1. Image viewer – Previous and next images are linked, hence can be accessed by next and previous button.
  2. Previous and next page in web browser – We can access previous and next url searched in web browser by pressing back and next button since, they are linked as linked list.
  3. Music Player – Songs in music player are linked to previous and next song. you can play songs either from starting or ending of the list.


luckys said...

english to marathi typing   

htop said...

nice blog
aws training center in chennai
aws training in chennai
aws training institute in chennai
best angularjs training in chennai
angular js training in sholinganallur
angularjs training in chennai
azure training in chennai

Vishal DurgaIT said...
This comment has been removed by the author.
anonymous said...

I really enjoyed your blog Thanks for sharing such an informative post.Looking For Some More Stuff.

shuttering works

anonymous said...

I really enjoyed your blog Thanks for sharing such an informative post.Looking For Some More Stuff.

best seo company in bangalore SSS digital Marketing

Durga IT Solutions said...
This comment has been removed by the author.
rajeev said...

Oracle Apps R12 and Fusion Cloud Self Paced Training Videos by Industry Experts. Please Check

Smith said...

Oracle Apps R12 and Oracle Fusion Cloud Self Paced Online Training Videos Published on Udemy with Life Time Access & Live Meeting Support to Clear your Queries. Avail 25% to 80% discount. Please Check for Never Before Offers and Discount Coupon Codes.

invincible01 said...

Amazing Article, Really useful information to all So, I hope you will share more information to be check and share here.

Inplant Training for cse
Inplant Training for IT
Inplant Training for ECE Students
Inplant Training for EEE Students
Inplant Training for Mechanical Students
Inplant Training for CIVIL Students
Inplant Training for Aeronautical Engineering Students
Inplant Training for ICE Students
Inplant Training for BIOMEDICAL Engineering Students
Inplant Training for BBA Students