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

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 334
    Comment on it

    Hi friends, Here I am writing a way to implement basic LinkedList.

    First of all LinkedList has the properties of List interface and AbstractSequentialList class because it implements List interface and extends AbstractSequentialList.

    Example :-

    LinkedList myLinkedList = new LinkedList(); 
      // add elements to the linked list 
    
      myLinkedList.add("A"); 
      myLinkedList.add("B"); 
      myLinkedList.add("C"); 
      myLinkedList.add("D"); 
      myLinkedList.add("E"); 
      myLinkedList.addLast("Z"); 
      myLinkedList.addFirst("F"); 
      myLinkedList.add(1, "F9"); 
      System.out.println("Values of linked list > > > > > " + myLinkedList); 
    
      // remove elements from the linked list 
      myLinkedList.remove("A"); 
      myLinkedList.remove(2); 
      System.out.println("Values of linked list after deleting >  > > > > "+ myLinkedList); 
    
      // remove first and last elements 
      myLinkedList.removeSecond(); 
      myLinkedList.removeLast(); 
    System.out.println("Values of linked list ----- " + myLinkedList); 
    
    
    } 
    } 
    

    Output:

    Values of linked list > > > > > [F, F9, A, B, C, D, E, Z] 
    Values of linked list after deleting >  > > > > [F, F9, C, D, E, Z] 
     Values of linked list -----: [F, C, D, E] 

 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: