Click here to watch in Youtube :https://www.youtube.com/watch?v=4ZMl-P3AQ4w&list=UUhwKlOVR041tngjerWxVccwVectorExample.java import java.util.Vector;
/*
* Example of clone() method
*/
public class VectorExample
{
public static void main( String[] args )
{
Vector<Integer> vector = new Vector<Integer>();
vector.add(10);
vector.add(20);
vector.add(30);
System.out.println("vector : " + vector);
/*
* Returns a clone of this vector. The copy will contain a reference to
* a clone of the internal data array, not a reference to the original
* internal data array of this Vector object.
*/
Object object = vector.clone();
Vector<Integer> clonedVector = (Vector<Integer>) object;
System.out.println("clonedVector : " + clonedVector);
}
}
Output vector : [10, 20, 30]
clonedVector : [10, 20, 30]