Vector class methods in Java Part -III

java.util.Vector

The Vector class implements a growable array of objects. Like an array, it contains components that can be accessed using an integer index. However, the size of a Vector can grow or shrink as needed to accommodate adding and removing items after the Vector has been created.


Some methods of Vector class.


replaceAll(UnaryOperator): This method replaces each element of this list with the result of applying the operator to that element.


retainAll(Collection): This method retains only the elements in this Vector that are contained in the specified Collection.


set(int, K): This method replaces the element at the specified position in this Vector with the specified element.


setElementAt(K, int): This method sets the component at the specified index of this vector to be the specified object.


setSize(int): This method sets the size of this vector.


size(): This method returns the number of components in this vector.


sort(Comparator): This method sorts this list according to the order induced by the specified Comparator.


spliterator(): This method creates a late-binding and fail-fast Spliterator over the elements in this list.


subList(int, int): This method returns a view of the portion of this List between fromIndex, inclusive, and toIndex, exclusive.


toArray(): This method returns an array containing all of the elements in this Vector in the correct order.


toArray(IntFunction): This method returns an array containing all of the elements in this collection, using the provided generator function to allocate the returned array.


toArray(K[]): This method returns an array containing all of the elements in this Vector in the correct order; the runtime type of the returned array is that of the specified array.


toString(): This method returns a string representation of this Vector, containing the String representation of each element.


trimToSize(): This method trims the capacity of this vector to be the vector's current size.


Some more methods of Vector class Part -I


Some more methods of Vector class Part -II


No comments:

Post a Comment