- Java Data Structures Resources
- Java Data Structures - Quick Guide
- Java Data Structures - Resources
- Java Data Structures - Discussion
Java Data Structures - Creating a Vector
The Vector class of the java.util class implements a dynamic array. It is similar to ArrayList, but with two differences where a Vector is synchronized and, it contains many legacy methods that are not part of the collections framework.
You can create a vector by instantiating the Vector class of the java.util package.
Vector vect = new Vector();
Example
import java.util.Vector;
public class CreatingVector {
public static void main(String args[]) {
Vector vect = new Vector();
vect.addElement("Java");
vect.addElement("JavaFX");
vect.addElement("HBase");
vect.addElement("Neo4j");
vect.addElement("Apache Flume");
System.out.println(vect);
}
}
Output
[Java, JavaFX, HBase, Neo4j, Apache Flume]
Advertisements