Question: Create a method tokenize that takes one String parameter and returns a String array composed of the words in the String. We will assume that

Create a method tokenize that takes one String parameter and returns a String array composed of the words in the String. We will assume that words in our String are separated by one space only, and that the sentence cannot end or begin with a space. For example, if the tokenize method is called with the String Thats one small step for a man, one giant leap for mankind.1 then the returned String[] array must contain 12 Strings: {Thats, one, small, step, for, a, man,, one, giant, leap, for, mankind.} The first step is to create a String[] array of the correct size. One suggestion is to write a helper method which counts the number of words in the String. Then, add the characters in the String into the individual Strings in the String array. For example, the characters T h a t s should be placed in the first String in the array, the characters o n e should be placed in the second String, and so on. You know to begin placing characters in the next String in the array when you reach the space character. Note that the split method cannot be used for this question. However, it may be helpful to test your results against the results of the split method.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!