Home » Java Vector clone() Method with Examples

Java Vector clone() Method with Examples

by Online Tutorials Library

Java Vector clone() Method

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:

Test it Now

Output:

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

Example 2:

Test it Now

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

You may also like