P
Peter
Hi, could someone help me with this silly problem I have. I am trying
to learn how to use Vectors and I want to 'flatten' them. I want my
for loop to print out
1
2.1
2.2
2.3.1
2.3.2
from the vector contents (I really want all the vectors and vectors of
vectors to be put in a String[]).
Thank you
Peter
BTW: here is the code I have that doesn't work.
package mypackage1;
import java.util.Vector;
public class Class1
{
public Class1()
{
}
public static void main (String[] args)
{
Vector v1=new Vector();
v1.add("1");
Vector v2=new Vector();
v2.add("2.1");
v2.add("2.2");
Vector v3=new Vector();
v3.add("2.3.1");
v3.add("2.3.2");
v2.add(v3);
v1.add(v2);
Object[] z=new Object[]{v1.toArray()};
for (int i=0;i<z.length;i++)
{
System.out.print("z["+String.valueOf(i)+"]=");
System.out.println(z);
}
}
}
to learn how to use Vectors and I want to 'flatten' them. I want my
for loop to print out
1
2.1
2.2
2.3.1
2.3.2
from the vector contents (I really want all the vectors and vectors of
vectors to be put in a String[]).
Thank you
Peter
BTW: here is the code I have that doesn't work.
package mypackage1;
import java.util.Vector;
public class Class1
{
public Class1()
{
}
public static void main (String[] args)
{
Vector v1=new Vector();
v1.add("1");
Vector v2=new Vector();
v2.add("2.1");
v2.add("2.2");
Vector v3=new Vector();
v3.add("2.3.1");
v3.add("2.3.2");
v2.add(v3);
v1.add(v2);
Object[] z=new Object[]{v1.toArray()};
for (int i=0;i<z.length;i++)
{
System.out.print("z["+String.valueOf(i)+"]=");
System.out.println(z);
}
}
}