Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Aim: Program To Implement Linkedlist Program:: Package Import Import Public Class Public Static Void New

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

AIM: Program to implement LinkedList

Program:
package hadoop;
import java.util.*;
import java.io.*;
public class LinkedListDemo {

public static void main(String args[]) {


// create a linked list
LinkedList l = new LinkedList();
// add elements to the linked list
l.add("F");
l.add("B");
l.add("D");
l.add("E");
l.add("C");
l.addLast("Z");
l.addFirst("A");
l.add(1, "A2");
System.out.println("contents of linked list: " + l);

l.remove("F");
l.remove(2);
System.out.println("linked list after deletion: " + l);

l.removeFirst();
l.removeLast();
System.out.println("linked list after deleting first and last
elements: " + l);

}
}

OUTPUT:

You might also like