Adding to a string array?
I have split my string into an array.
Hello im awesome
is now:
helloimawesome
I now want to add the spaces back into the array
so helloimawesome would be hello im awesome. I want to add a space only to hello and im. Can you even add new data to existing array elements?
Re: Adding to a string array?
Once an array is created, its size is set - so no, you cannot directly add new data to an existing array. You could manually create a larger array and copy the previous, or better yet use an ArrayList
ArrayList (Java Platform SE 6)
I do not know your intended goal, but you may also want to look into the StringBuilder / StringBuffer classes, which allow dynamic modification of Strings
StringBuilder (Java Platform SE 6)