import java.util.*;

class My_Point
{
    private int x,y;

    My_Point()
    {
	this( 0, 0 );
    }


    My_Point( int new_x, int new_y )
    {
	set( new_x, new_y);
    }

    void set ( int new_x, int new_y)
    {
	x=new_x;
	y=new_y;
    }

    void print()
    {
	System.out.println ( "("+ x + ", " + y + ")" );
    }
    
}


public class Array_List_Demo
{

    
    public static void main( String []args )
    {
	ArrayList alist = new ArrayList();
	
	

	alist.add("Monday");
	alist.add( new My_Point( 1, 3 ) );
	alist.add( "Tuesday" );
     
	System.out.println( "Size of list: " + alist.size() );
	
	System.out.println( "Tuesday is indexed at: " + alist.indexOf( "Tuesday" ) );
	alist.add( new My_Point (5, 9 ) );
	alist.add( "Friday" );
	System.out.print("Initial list\npos\twhat is there\n");
	for ( int i=0; i<alist.size(); i++ )
	    System.out.println( i+ " :\t" + alist.get(i));


	alist.remove(1);
	alist.remove(2);
	alist.add( new Integer(2) );
	alist.add(1, new Integer(1));
	
	System.out.print("List after removal of pos 1 & 2 and added new int (1) in pos 1 and new int (2) added to the end\npos\twhat is there\n" );
	for ( int i=0; i<alist.size(); i++ )
	    System.out.println( i + ":\t" + alist.get(i));


	
	System.out.print("List after pos 1 is replaced with a (1) & 2 with a (B) [set command was used for the replace]\npos\twhat is there\n" );	
for ( int i=0; i<alist.size(); i++ )
	    System.out.println( i+ " :\t" +alist.get(i));

	System.out.println("Convert the mess to a linked list");

	LinkedList l_list = new LinkedList( alist );
	System.out.println("Post conversion\npos\twhats there");

	for ( int i=0; i<alist.size(); i++ )
	    System.out.println( i+ " :\t" +l_list.get(i));

    }

}

