Question: Complete the two count methods. The bottom count method returns the number of times the target string appears in s (without overlapping). The top count

 Complete the two count methods. The bottom count method returns the

Complete the two count methods. The bottom count method returns the number of times the target string appears in s (without overlapping). The top count method returns the total number of times the target appears in all the strings in the array. The top count method should call the bottom count method.

Note.

1) The string array will have at least one string but the strings in the array may have a length of zero.

2) The target may be longer than some of the strings in the array.

3) The target will have a length of 1 or more.

public class Main { public static void main(String[] args) { String [] a = { "there are", "threeeee", "things that they", "threeeeeew" }; System.out.println( count( a, "th" ) ); // 6 System.out.println( count( a, "eee" ) ); // 3 System.out.println( count( a, "a" ) ); // 2 } public static int count( String [] S, String target ) { } public static int count( String s, String target ) { 1* use the indexOf method and a while loop please it's the best way to write this method */ } }

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!