This week's book giveaway is in the Game Development forum.
We're giving away four copies of Badass: Making Users Awesome and have Kathy Sierra on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes dynamic arrays Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Badass: Making Users Awesome this week in the Game Development forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "dynamic arrays" Watch "dynamic arrays" New topic

dynamic arrays

Thomas Whalen
Ranch Hand

Joined: Aug 26, 2001
Posts: 123
how do i create an array dynamically? i have seen examples of where ArrayB was a copy of ArrayA, but this isn't what I want to do. i want to take a string and create an array that will hold just that string.
thank you,

if you don't know, then ask. if you do know, then share. love is knowledge.
Marilyn de Queiroz

Joined: Jul 22, 2000
Posts: 9056
Have you seen the API for the String class?

You can use the
void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
method which copies characters from this string into the destination character array.

"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Thomas Whalen
Ranch Hand

Joined: Aug 26, 2001
Posts: 123
thanks for the example, i didn't even know to look in that API
I agree. Here's the link:
subject: dynamic arrays