Javatpoint Logo
Javatpoint Logo

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





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback

  • Send your Feedback to feedback@javatpoint.com

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA