Vector In Java

Vector In Java :

  • java.util package.
  • Vector class implements a growable array of objects.
  • Accessed using an integer index.
  • Vector is synchronized.
  • The vector contains many legacy methods that are not the part of a collections framework.
  • Default size vector is 10.
  • List v2 = new Vector(); // allows only the new (List) methods.
Vector In Java

vector class declare

public class Vector extends Object implements List, Cloneable, Serializable

Constructor :

1) vector(): Empty vector. Default size as 10.
2) vector(int initialCapacity):
3) vector(int initialCapacity, int capacityIncrement):
4) Vector( Collection c): Vector that contains the elements of a collection c.

Method :

1) add(): add vector.
2) add(i, o): Specific position insert element.
3) clear(): Remove all element from Vector.
4) contains: Return true or false.
5) firstElement: Return the first elelemnt.
6) lastElement: Return the last element.
7) get(position):
8) listIterator: Traverse the elelemnt.
9) remove(position): Remove the element specific position.
10) set(i, o): Sets the element at index i to o.
11) toArray(Object[]):
12) addAll(): Append all of the elements in the specified collection to the end of this Vector.
13) addElement(): Add end of this vector. It increases the vector size by one.
14) capacity(): get capacity current vector.
15) clone(): Clone of this vector.
16) copyInto(): Copy the components of the vector into the specified array.
17) elementAt() get the elelemnt at the specified index.
18) elements(): Returns an enumeration.
19) ensureCapacity(): capacity set vector.
20) equals(): Compare the specified object with the vector for equality.
21) forEach():
22) isEmpty():
23) insertElementAt():
24) trimToSize():
25) toString():
26) toArray():
27) subList():
28) spliterator():
29) sort():
30) size():
31) setSize():
32) setElementAt():
33) removeRange():
34) removeIf():
35) removeElementAt():
36) removeElement():
37) removeAllElements():
39) removeAll():