Example of Linked List

Here we write a program of Linked List.



package com.javaforecast4u;
import java.util.*;
public class ExampleLinkedList {

    /**
     * @author:arbind
     */
    public static void main(String[] args) {
   
         LinkedList ll=new LinkedList();
         ll.add("java");
         ll.add("fore");
         ll.add("cast");
         ll.add("4u");
         System.out.println(ll);
         ll.add(3,"arbind");
         System.out.println(ll);
         System.out.println(ll.getFirst());
         System.out.println(ll.getLast());
         System.out.println("..........................");
         System.out.println(ll.removeFirst());
         System.out.println(ll.removeLast());
         ll.addFirst("aa");
         System.out.println(ll);
         ll.addLast("bb");
         System.out.println(ll);
   
    }

}

0 comments :

Post a Comment