If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

copying a string into array of string

Hello,
I want to copy a string into array of strings. I used system.copyarray(...),but it only works for the same type of array. Now i have a string containing a lot of words and i want to assigne each word to an elemnt of the stringarray.

Aternate method

Hi! I'm new to this forum but I saw your question and I felt I had something to add.

Using Java SDK from version 1.4 you can use the java.lang.String.split() method.
This method offers a very convinient solution to your problem, taking a regular expression String as parameter and returning an array of Strings.

In your case you wold have to write:

String[] words = str.split(" ");

and it will do the same as the StringTokenizer but with only one line of code.