Java Vector clone() Method

24 Mar 2025 | 2 min read

The clone() method of Java Vector class is used to get a clone of the vector which is in use.

Syntax:

Following is the declaration of clone() method:

Parameter:

This method does not accept any parameter.

Returns:

This method returns a clone of the vector which is in use.

Exceptions:

NA

Compatibility Version:

Java 1.2 and above

Example 1:

Output:

 Original vector: [Tiger, Deer, Dog, Camel] Cloned vector: [Tiger, Deer, Dog, Camel] 

Example 2:

Output:

 Elements in vector are: Number = 4 Number = 3 Number = 2 Number = 1 Elements in vecclone vector are: Number = 4 Number = 3 Number = 2 Number = 1 
 
Next TopicJava Vector