Find a substring

Report a typo

Write a recursive method called indexOf that accepts two strings as parameters and returns the starting index of the first occurrence of the second string inside the first string (or -1 if not found).

Sample Input 1:

Java
J

Sample Output 1:

0

Sample Input 2:

Hyper
Er

Sample Output 2:

-1
Write a program in Java 17
class Util {
public static int indexOf(String src, String tgt) {
// your code here
return -1;
}
}
___

Create a free account to access the full topic