Q:

what is vector in java

// Java code illustrating add() method 
import java.util.*; 
class Vector_demo { 
    public static void main(String[] arg) 
    { 
  
        // create default vector 
        Vector v = new Vector(); 
  
        v.add(1); 
        v.add(2); 
        v.add("geeks"); 
        v.add("forGeeks"); 
        v.add(3); 
  
        System.out.println("Vector is " + v); 
    } 
}
0
Array based data structure/Internally uses
dynamic array.
-It is synchronized - thread safe.
-It is mostly used in multi-threaded environment.
-It is much slower than ArrayList because it is
thread-safe
0

New to Communities?

Join the community