Vector class Methods in Java Part -I

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.


add(K)This method appends the specified element to the end of this Vector.


add(int, K)This method inserts the specified element at the specified position in this Vector.


addAll(Collection)This method appends all of the elements in the specified Collection to the end of this Vector, in the order that they are returned by the specified Collection's Iterator.


addAll(int, Collection)This method inserts all of the elements in the specified Collection into this Vector at the specified position.


addElement(K)This method adds the specified component to the end of this vector, increasing its size by one.


capacity()This method returns the current capacity of this vector.


clear()This method removes all of the elements from this Vector.


clone()This method returns a clone of this vector.


contains(Object)This method returns true if this vector contains the specified element.


containsAll(Collection)This method returns true if this Vector contains all of the elements in the specified Collection.


copyInto(Object[])This method copies the components of this vector into the specified array.


elementAt(int)This method returns the component at the specified index.


elements()This method returns an enumeration of the components of this vector.


ensureCapacity(int)This method increases the capacity of this vector, if necessary, to ensure that it can hold at least the number of components specified by the minimum capacity argument.


equals(Object)This method compares the specified Object with this Vector for equality.


firstElement()This method returns the first component (the item at index 0) of this vector.


forEach(Consumer)This method performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception.


get(int)This method returns the element at the specified position in this Vector.


Some more methods of Vector class Part -II


Some more methods of Vector class Part -III




No comments:

Post a Comment