Java Vector contains() Method24 Mar 2025 | 1 min read 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: Parameter:
Returns:The contains() method returns true if this vector contains the specified element, otherwise returns false. Exceptions:NA Compatibility Version:Java 1.2 and above Example 1:Output: Java is present at the index 1 Example 2:Output: Existence: true Next TopicJava Vector |
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 spliterator() method of Java Vector class is used to create a late-binding and fail-fast spliterator over the elements in this list. Syntax Following is the declaration of spliterator() method: public Spliterator<E> spliterator() Parameter This method does not accept any parameter. Return The spliterator() method returns a spliterator over the...
2 min read
Java Method The setSize() method of Java Vector class is used to set the size of a vector. If the new size is greater than the current size, null items are added to the end of the vector. Otherwise, all components at index newSize and...
3 min read
Java Method The removeElement() method of Java Vector class is used to remove the first (lowest-indexed) occurrence of the argument from this vector. Removing an element decreases the vector size by one. Syntax Following is the declaration of removeElement() method: Public boolean removeElement(Object obj) Parameter Parameter Description Required/Optional obj It is an element which...
2 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 removeAllElements() method of Java Vector class is used to remove all elements from the vector and set the size of the vector to zero. Syntax Following is the declaration of removeAllElements() method: Public void removeAllElements() Parameter This method does not accept any parameter. Return This method has return type...
2 min read
Java Method The clear() method of Java Vector class is used to remove all of the elements from the vector which is in use. Syntax: Following is the declaration of clear() method: Public void clear() Parameter: This method does not accept any parameter. Returns: This method has return type void so, it...
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 retainAll() method of Java Vector class is used to retain only that elements in the vector which are contained in the specified collection. In other words, it removes all elements from this vector that are not contained in the specified collection. Syntax Following is...
3 min read
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
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