package com.collection;

import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Vector;

public class ListDemo {
public static void main(String[] args) {

ArrayList al=new ArrayList<>();
al.add(100);
al.add(40);
al.add(0,4);
al.add(800);
al.add(1,50);
al.add(8);
System.out.println(al);

System.out.println(al.size());

System.out.println(al.get(2));

System.out.println(al.remove(0));

System.out.println(al);

ListIterator li=al.listIterator();

System.out.println(" ListIterator Demo ");
while(li.hasNext())
System.out.println(li.nextIndex()+" "+li.next());

System.out.println(" Previous Direction ");
while(li.hasPrevious())
System.out.println(li.previousIndex()+" "+li.previous());



Vector v=new Vector<>();
v.addElement(400);
v.add(40);
v.add(-92);
v.add(-90);
v.add(4);
v.add(400);
v.add(400);
v.add(5000);
v.add(800);

System.out.println(v);

v.remove(0);
System.out.println(v);

Collections.sort(v);
System.out.println(v);


LinkedList ll=new LinkedList<>();


ll.add(400);
ll.add(10);
ll.addFirst(0);
ll.addLast(600);
ll.add(7);
ll.add(1,v);
ll.add(2,al);
System.out.println(ll);

System.out.println(ll.get(0));
System.out.println(ll.getFirst());
System.out.println(ll.getLast());

System.out.println("Peek "+ll.peek());
System.out.println(ll);
System.out.println("peek First "+ll.peekFirst());

System.out.println(ll);
System.out.println("poll "+ll.poll());
System.out.println(ll);
System.out.println("Poll "+ll.pollFirst());

ll.add(500);
System.out.println(ll);
System.out.println(ll.poll());
System.out.println(ll);



}



}