How to create LinkedList in Java?

The following line is used to create LinkedList. LinkedList linkedList= new inkedList(); This peace of code used to add value to LinkedList. linkedList.add("B");


								
package com.mindclues;


import java.util.LinkedList;

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

    LinkedList linkedList = new LinkedList();
    linkedList.add("B");
    linkedList.add("C");
    linkedList.add("D");
    linkedList.add("E");

    System.out.println(" Linked List : " + linkedList);
  }
}
							

								
Linked List : [B, C, D, E]
							

Related Articles

post a comment