Home Segments Top Top Previous Next

559: Mainline

You declare Vector variables just as you would any variable to which class instances are assigned. For example, to declare v to be a variable to which a vector will be assigned, you write the following:

  *-- Declare a Vector variable 
  v 
--------- 
Vector v; 

To create a vector instance, you deploy the new operator:

 *-- Create a Vector instance 
 v 
------------ 
new Vector() 

To declare a vector variable and to create an instance in the same statement, you combine variable declaration and vector creation:

  *-- Declare 
  |          *-- Create 
  v          v 
--------   ------------ 
Vector v = new Vector();