Java Topics

Vector

 ✓The methods of Vector are synchronised.

✓ Vector is a thread safe class.

✓ Vector is introduced in JDK 1.0 and it is a legacy/old class.

Properties of vector:

✓ Insertion order is preserved

✓ Indexd type of collection

✓ Multiple null values are allowed

✓ Duplicates are allowed.

ex:

   class Vector{

   public static void main (String[ ] args){

     Vector v=new Vector();

     v.add("java");

     v.add("sql");

     v.add(10);

      v.add(10);

    for(int i=0;i<v.size();i++){

       System.out.println(v.get(i));

     }

 }

}

Output:

java

sql

10

10