Answered step by step
Verified Expert Solution
Question
1 Approved Answer
NOTE THAT THE SPLIT METHOD CANNOT BE USED. 2c) Tokenize method The methods in this question operate on words within a String. Therefore, we require
NOTE THAT THE SPLIT METHOD CANNOT BE USED.
2c) Tokenize method The methods in this question operate on words within a String. Therefore, we require a method to divide a String into its t words. 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 "That's one small step for a man, one giant leap for mankind."1 then the returned String[] array must contain 12 Strings: {' 'That's, , , '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 methodStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started