Question: Your pre - lab task is to familiarize yourself with string tokenization Create an Eclipse project Create a package called prelab Create a split method,

Your pre-lab task is to familiarize yourself with string tokenization
Create an Eclipse project
Create a package called prelab
Create a "split" method, which takes in a string, and a character delimiter.
a. Count how many times the delimiter occurs within the string
i. Using indexof may be helpful here
b. Create an array of strings based on the result of (a)
c. For each occurrence of the delimiter, place the corresponding substrings in the array
you created
i. indexof and substring functions of a String class will be really useful here
d. Return the array
Create a main method which:
a. Prompts the user to enter a string (a line of text)
b. Split the string based on spaces, and display each result to the user (1 per line)
c. Split the string based on periods, and display each result to the user (1 per line)
i. Ensure your results here are correct, periods act strangely with split
Do not use the String class's split method.
You may wish to make a print function which takes in an array of strings, to avoid repetition of
code
 Your pre-lab task is to familiarize yourself with string tokenization Create

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!