Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Web Database Development Step By Step

Authors: Jim Buyens

1st Edition

0735609667, 978-0735609662

More Books

Students also viewed these Databases questions