Java Vector size() Method24 Mar 2025 | 1 min read The size() method of Java Vector class is used to get the number of components presents in the vector. SyntaxFollowing is the declaration of size() method: ParameterThis method does not accept any parameter. ReturnThe size() method returns the number of components presents in a vector. ExceptionsNA Compatibility VersionJava 1.2 and above Example 1Output: The vector Element is = [10, 20, 30, 40, 50] Size of the vector is = 5 Example 2Output: Size of the vector is = 4 Next TopicJava Vector Sort Method |
Java Method The forEach() method of Java Vector class is used to perform the given action for each element of the Iterable until all elements have been processed or the action throws an exception. Actions are performed in the order of iteration if that order...
2 min read
Java Method The indexOf() Java Vector class method is used to get the index of the first occurrence of the specified element in the vector. There are two different types of Java indexOf() method which can be differentiated depending on its parameter. These are: Java Vector...
3 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 containsAll() method of Java Vector class is used to check the vector which is in use contains all of the elements in the specified Collection or not. It returns true if this vector contains all of the elements in the Collection, otherwise...
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 setElementAt() method of Java Vector class is used to replace the component at the specified index of this vector to be the specified object. Syntax Following is the declaration of setElementAt() method: public void setElementAt(E obj, int index) Parameter Parameter Description Required/Optional index It is the specified index where an element...
2 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 capacity() method of Java Vector class is used to get the current capacity of the vector which is in use. Syntax: Following is the declaration of capacity() method: Public int capacity() Parameter: This method does not accept any parameter. Returns: This method returns the current capacity of the vector...
2 min read
Java Method The subList() method of Java Vector class is used to get a view of the portion of the list between fromIndex, inclusive, and toIndex, exclusive. If fromIndex and toIndex are equal, the returned List is empty. Syntax Following is the declaration of subList() method: Public List<E>...
3 min read
Java Method The lastIndexOf() Java Vector class method is used to get the index of the last occurrence of the specified element in the vector. There are two different types of Java lastIndexOf() method which can be differentiated depending on its parameter. These are: Java Vector...
3 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