Question: Suppose we have a string holding the text of an entire book. If we want to analyze segments of the text, it is inefficient to
Suppose we have a string holding the text of an entire book. If we want to analyze segments of the text, it is inefficient to make substrings. Instead, we should just store a reference to the original text and the starting and ending positions. Design a class Segment that does this, and have it implement the CharSequence interface of the standard library. Write a test program in which you demonstrate that you can pass your Segment objects to methods that accept CharSequence instances, such as String.join and PrintStream.append.
Step by Step Solution
3.49 Rating (156 Votes )
There are 3 Steps involved in it
Sure we can definitely implement this Our solution will involve creating a Segment class that implements CharSequence interface and then testing this ... View full answer
Get step-by-step solutions from verified subject matter experts
