Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Converting a Vector into a String[ ][ ] Array

807569May 22 2006 — edited May 22 2006
I am trying to use a vector to get the ability to add elements dynamically. But, in certain parts of my code, I need to have it become an array.

I have found the Vector.toArray() API from searching on this forum so far.
http://java.sun.com/j2se/1.4.2/docs/api/java/util/Vector.html#toArray()


How do I make sure I initilize the array to the correct size?
        Vector dataVector2 = new Vector();
        String[][] data2 = new String[4][8];   //4 = rows, 8 = columns.  But if I add a
                                               //fifth row, how can I code it to look for
                                               //that while the program is running?

        //To convert it, is it just
        data2 = dataVector2.toArray();
Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 19 2006
Added on May 22 2006
5 comments
239 views