Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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 method

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

More Books

Students also viewed these Databases questions