This is a common task I\'m facing: splitting a space separated list into a head element and an array containing the tail elements. For example, given this
Use StringTokenizer and a while loop to step through each element. Inside the loop, you can get the first element and put the rest into an array.
Edit: Oh, I guess StringTokenizer is a "legacy" class (though it still works).
The recommended way is now to use String.split(). That will give you a String[] containing your elements. From there it should be trivial to get the first element and also create an array out of the remaining elements.