Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • LinkedList class

    • 0
    • 2
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 595
    Comment on it

    LinkedList class:

    It provides a linked-list data structure. It uses doubly linked-list to store elements. It extends the AbstractList class and implements List  interface. We can use LinkedList class by importing java.util package.

    Example:

    import java.util.*;
    
    public class ListDemo {
    
       public static void main(String args[]) {
          // create a linked list
          LinkedList ll = new LinkedList();
          // add elements to the linked list
          ll.add("F");
          ll.add("B");
          ll.add("D");
          ll.add("E");
          ll.add("C");
          ll.addLast("Z");
          ll.addFirst("A");
          ll.add(1, "A2");
          System.out.println("Original contents of ll: " + ll);
    
          // remove elements from the linked list
          ll.remove("F");
          ll.remove(2);
          System.out.println("Contents of ll after deletion: "
           + ll);
          
          
    
          
       }
    }

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: