Question: Write a Java program from scratch that meets the following requirements: a . The program is in a file called Matching.java that defines a class

Write a Java program from scratch that meets the following requirements:
a. The program is in a file called Matching.java that defines a class called
Matching.
b. The program includes a Java method called find that takes two Strings and
returns an integer. If the second string does not appear in the first string, find
returns -1. If the second string appears in the first string, find returns the index
of the character where the second string begins in the first string. Make sure the
method is public static.
example tests:
find("","") returns 0
find("","a") returns -1
find("Hello World", "World") returns 6
find("World", "Hello World") returns -1
find("Hello World", "lo W") returns 3
hint: you will find the length and charAt methods of String useful. To call them on a String x,
you would do x.length() and x.charAt(i)(where i is whatever index in the String you want to
get). Alternatively to x. charAt, you could use x. toCharArray to get a char[] containing the
characters.
Java's String has a method (indexof) that does nearly the same thing as find(); however, we do
not want you to use index of in your solution to this problem.
c. The program's main method calls find on the above test cases and prints each
return value.
 Write a Java program from scratch that meets the following requirements:

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!