Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Complete the body of the following private static method. /** * Returns the first word (maximal length string of characters not in * {@code SEPARATORS})

Complete the body of the following private static method.

/**

* Returns the first "word" (maximal length string of characters not in

* {@code SEPARATORS}) or "separator string" (maximal length string of

* characters in {@code SEPARATORS}) in the given {@code text} starting at

* the given {@code position}.

*

* @param text

* the {@code String} from which to get the word or separator

* string

* @param position

* the starting index

* @return the first word or separator string found in {@code text} starting

* at index {@code position}

* @requires 0 <= position < |text|

* @ensures

 

* nextWordOrSeparator =

* text[position, position + |nextWordOrSeparator|) and

* if entries(text[position, position + 1)) intersection entries(SEPARATORS) = {}

* then

* entries(nextWordOrSeparator) intersection entries(SEPARATORS) = {} and

* (position + |nextWordOrSeparator| = |text| or

* entries(text[position, position + |nextWordOrSeparator| + 1))

* intersection entries(SEPARATORS) /= {})

* else

* entries(nextWordOrSeparator) is subset of entries(SEPARATORS) and

* (position + |nextWordOrSeparator| = |text| or

* entries(text[position, position + |nextWordOrSeparator| + 1))

* is not subset of entries(SEPARATORS))

*

*/

private static String nextWordOrSeparator(String text, int position) {...}

The "separators" are defined as a String constant as follows:

/**

* Definition of whitespace separators.

*/

private static final String SEPARATORS = " \t ";

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

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions