
/*

	Tom DeDonno 

	Vector Class

		dynamic 1-D data Structures

	This class demonstrates 7 Vector Methods
          capacity, size, isEmpty, elementAt, addElement,
          removeElement and setElementAt
        Program adds two types of Objects to Vector

 */
import java.util.Vector;

public class MyVector {

	public static void print( Vector v1, String comment ) {

		System.out.println( comment );
                System.out.print( "Vector Capacity is:" + v1.capacity() );
		System.out.println( " Number of Vector Elements is: " + v1.size() );
		System.out.print( "Vector Empty? " + v1.isEmpty() );
		System.out.println( " Vector Elements..." );
		for( int i=0; i < v1.size() ; ++i )
			System.out.println( v1.elementAt( i ) );
                System.out.println( "===== Continue =======" );
                SavitchIn.readLine();
              }
                
      public static void main( String[] args ) {
        
          Vector v = new Vector( 5, 6 );
          
		{
		String[] a = {"Hi Everyone", "Hi Furby", "Hi Mom", "Hi Shelby" };
		// set elements of type String at 0..3
                for( int i = 0; i < a.length ; ++i )
                        v.addElement( a[i] );
		} 
		//What is scope of a? scope of v
		//System.out.println( "a = " + a[0] );
                
		print( v, "Capacity should be 5, size 4 Strings" );
		
		// Add Integer Objects to locations 4..14
		for( int i = 4 ; i < 10 ; ++i )
			v.addElement( new Integer( i ) );
		print( v, "Capacity should be 5+6 size 10 Elements" );
                                
                v.removeElement( "Hi Mom" );
                v.setElementAt( "GoodBye", 0);
                print( v,
                "Capacity still 11 size 9, removed Hi Mom, Goodbye 1st element" );
                
                           
		} //End main
} //end MyVector
