Vector class clone()method example
Returns a clone of this vector.
Vector class clone()method example. This example shows you how to use clone()method.This method Returns a clone of this vector.
Here is the code:-
/*
* @Program that Returns a clone of this vector.
* Clone.java
* Author:-RoseIndia Team
* Date:-24-May-2008
*/
import java.util.*;
public class Clone {
public static void main(String[] args) {
//creating vector
Vector v= new Vector();
v.add("girish");
v.add("tewari");
//creating enumeration interface
Enumeration E=v.elements();
System.out.print("Element in the vector are: ");
while(E.hasMoreElements())
{
System.out.println(E.nextElement());
}
// Returns a clone of this vector.
Object o=v.clone();
System.out.println("Clone of the vector is :"+o);
}
} |
Output of the program:-
Element in the vector are: girish
tewari
Clone of the vector is :[girish, tewari] |
|