LinkedList

package lsit;

import java.util.LinkedList;

import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;

public class linkedlist {
 
    public static void main(String a[]){
         
        LinkedList ll = new LinkedList();
        ll.add("Orange");
        ll.add("Apple");
        ll.add("Grape");
        ll.add("Banana");
        
    /*    //(1) to show all linikedlist element
        System.out.println(ll);*/
        
      /*  //(2) to show size of linkedlist contain element
        System.out.println("Size of the linked list: "+ll.size());*/
        
        
        /*//(3) to check linkedlist either contain element or not----it is boolean type
        System.out.println("Is LinkedList empty? "+ll.isEmpty());*/
        
        
        
      /*  //(4) TO check any specified object are found in linkedlist or not--It is boolean type
        System.out.println("Does LinkedList contains 'Grape'? "+ll.contains("Grape"));*/
        
        
/*        //(5) clone of linkedlist
        System.out.println("Initial list"+ll);
        LinkedList copy = (LinkedList)ll.clone();
        System.out.println("Cloned LinkedList:"+copy);*/
        
      /*  //(6) add arraylist element at linked list
        List list = new ArrayList();
        list.add("one");
        list.add("two");
        ll.addAll(list);
        System.out.println("After Copy: "+ll);*/
        
        
    /*    //(7) to delete all element of linkedlist
        System.out.println("Actual LinkedList:"+ll);
        ll.clear();
        System.out.println("After clear LinkedList:"+ll);*/
        
        
      /*  //(8) check linkedlist contain all element or not
        List list = new LinkedList();
        list.add("Second");
        list.add("Random");
        System.out.println("Does LinkedList contains all list elements?: "+ll.containsAll(list));
        list.add("one");
        System.out.println("Does LinkedList contains all list elements?: "+ll.containsAll(list));
        ll.addAll(list);
        System.out.println("After Copy: "+ll);
        System.out.println("Does LinkedList contains all list elements?: "+ll.containsAll(list));*/
        
     /*   //(9) convert linkedlist to array
        System.out.println("Actual LinkedList:"+ll);
        String[] strArr = new String[ll.size()];
        ll.toArray(strArr);
        System.out.println("Created Array content:");
        for(String str:strArr){
            System.out.println(str);
        }
        */
        
        /*//(10) sublist of linkedlist
        List list = ll.subList(2, 4);
        System.out.println("Sub List: "+list);*/
        
     /*  //(11) reverse linked list 
        System.out.println("Initial order of linkedlist"+ll);
        Collections.reverse(ll);
        System.out.println("Results after reverse operation:");
        for(String str: ll){
            System.out.println(str);
        }
*/

        
      /*  //(12) suffle linkedlist element
        System.out.println("Initial order of linkedlist"+ll);
        Collections.shuffle(ll);
        System.out.println("Results after shuffle operation:");
        for(String str: ll){
            System.out.println(str);
        }
*/
        
        /*//(13) swap two elements
        System.out.println("Initial order of linkedlist"+ll);
        Collections.swap(ll, 1, 3);
        System.out.println("Results after swap operation:");
        for(String str: ll){
            System.out.println(str);
        }*/

        
       /* //(14) add element at specified index
        System.out.println("Initial order of linkedlist"+ll);
        ll.addFirst("I am first");
        System.out.println("After changes in linkedlist"+ll);*/
        
        
     /*  //(15) addLast(): Appends the specified element to the end of this list.
       //(16) offerLast(): Inserts the specified element at the end of this list.
       //(17) offer(): Adds the specified element as the tail (last element) of this list.

        System.out.println("Initial order of linkedlist"+ll);        
        System.out.println("Adding element at last position...");
        ll.addLast("I am last");
        System.out.println(ll);
        System.out.println("Adding element at last position...");
        ll.offerLast("Ashi");
        System.out.println(ll);
        System.out.println("Adding element at last position...");
        ll.offer("Unmesh ASHI");
        System.out.println(ll);*/

       /*//(18) element(): Retrieves, but does not remove, the head (first element) of this list.
       //(19) getFirst(): Returns the first element in this list.
       //(20) peek(): Retrieves, but does not remove, the head (first element) of this list.
       //(21) peekFirst(): Retrieves, but does not remove, the first element of this list,or returns null if this list is empty.

        
        System.out.println("First Element: "+ll.element());
        System.out.println("First Element: "+ll.getFirst());
        System.out.println("First Element: "+ll.peek());
        System.out.println("First Element: "+ll.peekFirst());
*/
        
        
      /*  //(22)getLast(): Returns the last element in this list.
        //(23)peekLast(): Retrieves, but does not remove, the last element of this list,or returns null if this list is empty.

        System.out.println("Object of LinkedList"+ll);
        System.out.println("Last Element: "+ll.getLast());
        System.out.println("Last Element: "+ll.peekLast());
*/
     /*   
        //(24) reverse linkedlist 
        System.out.println(ll);
        
        Iterator itr = ll.descendingIterator();
        while(itr.hasNext()){
            System.out.println(itr.next());
        }*/

  /*      //(25)push(): Pushes an element onto the stack represented by this list.
        //(26)pop(): Pops an element from the stack represented by this list.

        System.out.println("Object of LinkedList"+ll);
        ll.push("push element");
        System.out.println("After push operation:");
        System.out.println(ll);
        ll.pop();
        System.out.println("After pop operation:");
        System.out.println(ll);*/

        
        
       //(27) remove(): Retrieves and removes the head (first element) of this list.
       //(28) remove(index): Removes the element at the specified position in this list.
      
       //(29) removeFirst(): Removes and returns the first element from this list.
       
        
        
        System.out.println("intial order of linkedlist"+ll);
        System.out.println("Remov() method:"+ll.remove());
        System.out.println("After remove() method call:");
        System.out.println(ll);
        System.out.println("remove(index) method:"+ll.remove(2));
        System.out.println("After remove(index) method call:");
        System.out.println(ll);
       
        System.out.println("removeFirst() method:"+ll.removeFirst());
        System.out.println("After removeFirst() method call:"+ll);

        
        
    }
}

          

Address

Plot number-56/1
Near Gurudwara
LandMark :
Opposite A.N.D college
Govindpuri Metro station
New Delhi
Mobile number:
8826034620