What's wrong in my copyInto statment
Hi,
A make a simple copyInto statment that is crashed and I don't understand why ?
Thanks in advance.
Here is a snipset of my code
Vector v= new Vector();
String[] labels=new String[v.size()];
log=rs.getString("ORIG_SUBMITTER");
v.add(j,new String(log));
v.copyInto(String[] labels);
I'm not sure exactly what your problem was, but this works:
java.util.Vector v= new java.util.Vector();
String log="this is a test";
v.add(log);
log="this is another test";
v.add(log);
String[] labels=new String[v.size()];
v.copyInto((String[]) labels);
System.out.println("length = " + labels.length + " values: " + labels[0] + " " + labels[1]);
Hi
According to my Java Help Files that i have available is you are calling for the size of the Vector to initiate the String Array but the contsructor that you have used have created an empty Vector.
public Vector()
//Constructs an empty vector.
public Vector(int initialCapacity)
//Constructs an empty vector with the specified initial capacity.
//Parameters:
//initialCapacity - the initial capacity of the vector.
public Vector(int initialCapacity, int capacityIncrement)
//Constructs an empty vector with the specified initial capacity and capacity increment.
//Parameters:
//initialCapacity - the initial capacity of the vector.
//capacityIncrement - the amount by which the capacity is increased when the vector verflows.
//Vector
Well I hope this helps you.
Ciao