Win a copy of Functional Reactive Programming this week in the Other Languages forum!

# creating names for vectors

Donna Bachner
Ranch Hand
Posts: 109
I want to make an unlimited number of vectors and need to call then something to keep track of them is there a way to do this. I have code that I want to avoid

if(POI > 2 )
{
Vector POI3 = new Vector();
System.out.println("Enter POI one number at a time DO NOT enter the comma's ");
for(int i = 1; i <= len; i++)
{
int p = Integer.parseInt(input);
}
Enumeration EnPOI3 = POI3.elements();
while(EnPOI3.hasMoreElements())
System.out.print(EnPOI3.nextElement() +", ");
System.out.println();
System.out.println("Enter coordinates");
}
if(POI > 3 )
{
Vector POI4 = new Vector();
System.out.println("Enter POI one number at a time DO NOT enter the comma's ");
for(int i = 1; i <= len; i++)
{
int p = Integer.parseInt(input);
}
Enumeration EnPOI4 = POI4.elements();
while(EnPOI4.hasMoreElements())
System.out.print(EnPOI4.nextElement() +", ");
System.out.println();
System.out.println("Enter coordinates");
}
Vector v1 = new Vector();
System.out.println("Enter vector one number at a time DO NOT enter the comma's ");
for(int i = 0; i < len; i++)
{
int p = Integer.parseInt(input);

}
if(number > 1 )
{
Vector v2 = new Vector();
System.out.println("Enter vector one number at a time DO NOT enter the comma's ");
for(int i = 1; i <= len; i++)
{
int p = Integer.parseInt(input);
}
}
if(number > 2 )
{
Vector v3 = new Vector();
System.out.println("Enter vector one number at a time DO NOT enter the comma's ");
for(int i = 1; i <= len; i++)
{
int p = Integer.parseInt(input);
}
}
if(number > 3 )
{
Vector v4 = new Vector();
System.out.println("Enter vector one number at a time DO NOT enter the comma's ");
for(int i = 1; i <= len; i++)
{
int p = Integer.parseInt(input);

}

Keith Lynn
Ranch Hand
Posts: 2409
What about an array of Vectors?

Donna Bachner
Ranch Hand
Posts: 109
can you have that. I never tried. Thanks

Keith Lynn
Ranch Hand
Posts: 2409
Yes, you can create an array of object references.

Jeff Albertson
Ranch Hand
Posts: 1780
Given that you want an unlimited number, why not a Vector of Vectors, or an ArrayList of ArrayLists?

Donna Bachner
Ranch Hand
Posts: 109
Thank you everyone I got it working.