source file name:  vectordemo1.java

import java.util.*;

class vectordemo1

{

public static void main(String as[])

{

System.out.println("vector demo program");

Vector v1=new Vector();

String s1="one";

String s2="two";

Integer il=new Integer(100);

Float f=new Float(2.53f);

v1.add(s1);

v1.add(il);

v1.add(f);

v1.insertElementAt(s2,2);

System.out.println("vector v1= "+v1);

Object obarr[]=new Object[v1.size()];

v1.copyInto(obarr);

System.out.println("list objects from array:");

for(int i=0;i<obarr.length;i++)

System.out.print(obarr[i]+" ");

v1.remove(1);

obarr=v1.toArray();

System.out.println("\n list objects from array removing");

for(int i=0;i<obarr.length;i++)

System.out.println(obarr[i]);

}

}

output:

D:\JavaPrograms\Misc>javac vectordemo1.java

Ignore this two messages still program execute.

D:\JavaPrograms\Misc>java vectordemo1

vector demo program

vector v1= [one, 100, two, 2.53]

list objects from array:

one 100 two 2.53

 list objects from array removing

one

two

2.53