Java Vector clone() Method24 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 |
Java Method The lastElement() method of Java Vector class is used to get the last component of the vector. Syntax Following is the declaration of lastElement() method: Public E lastElement() Parameter This method does not accept any parameter. Return The lastElement() method returns the last element of the vector i.e. the component...
2 min read
Java Method The contains() method of Java Vector class is used to check the vector which is in use contains the specified element or not. It returns true if this vector contains the specified element, otherwise returns false. Syntax: Following is the declaration of contains() method: public boolean...
2 min read
Java Method The size() method of Java Vector class is used to get the number of components presents in the vector. Syntax Following is the declaration of size() method: public int size() Parameter This method does not accept any parameter. Return The size() method returns the number of components presents in a...
2 min read
Java Method The listIterator() Java Vector class method returns a list iterator over the elements in the given list in a proper sequence. There is two different types of Java listIterator() method which can be differentiated depending on its parameter. These are: Java Method Java Vector...
4 min read
Java Method The add() is a Java Vector class method which is used to insert the specified element in the given Vector. There are two different types of Java add() method which can be differentiated depending on its parameter. These are: Java Vector add(int index, E...
3 min read
Java Method The get() method of Java Vector class is used to get the element at the specified position in the vector. Syntax Following is the declaration of get() method: public E get(int index) Parameter DataType Parameter Description Required/Optional int index It is an index of the element which will be returned. Required Return The get() method returns the...
2 min read
Java Method The set() method of Java Vector class is used to replace the element at the specified position in the vector with the specified element. Syntax Following is the declaration of set() method: Public E set(int index, E element) Parameter Parameter Description Required/Optional index It is an index of the element which will...
2 min read
Java Method The equals() method of Java Vector class used to compare the specified object with this Vector for equality. It returns true if and only if the specified object is also a list, both lists have the same size and all corresponding pairs of...
2 min read
Java Method The elementAt() method of Java Vector class is used to get the element at the specified index in the vector. Syntax Following is the declaration of elementAt() method: public E elementAt(int index) Parameter DataType Parameter Description Required/Optional int index It is an index into this vector. Required Return The elementAt() method returns an element at the specified...
2 min read
Java Method The ensureCapacity() method of Java Vector class is used to increase the capacity of the vector which is in use, if necessary. It ensures that the vector can hold at least the number of components specified by the minimum capacity argument. Syntax: Following is the...
2 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India