Question: Write a recursive method indexOf that accepts two Strings as parameters and that returns the starting index of the first occurrence of the second String

 Write a recursive method indexOf that accepts two Strings as parameters

Write a recursive method indexOf that accepts two Strings as parameters and that returns the starting index of the first occurrence of the second String inside the first String (or -1 if not found). The table below lists several calls to your method and their expected return values. Notice that case matters, as in the last example that returns -1 Call Value Returned indexOf ("Barack Obama", "Bar") indexOf ("Barack Obama", "ck") indexof("Barack Obama", "a") indexof ("Barack Obama", "McCain") -1 indexOf ("Barack Obama", "BAR") 4 Strings have an indexOf method, but you are not allowed to call it. You are limited to these methods Method Description equals (String other) length() substring(int fromIndex, int toIndex) returns a new String containing the characters from this String from fromIndex substring(int fromIndex) returns true if the two Strings contain the same characters returns the int number of characters in the String (inclusive) to toIndex (exclusive), or to the end of the String if toIndex is omitted You are not allowed to construct any structured objects other than Strings (no array, List, Scanner, etc.) and you may not use any loops to solve this problem, you must use recursion

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!