Question: Create a method that gets an array of strings and a string, the method returns an int. It counts how many times a string appears

Create a method that gets an array of strings and a string, the method returns an int.

It counts how many times a string appears in the array and returns the count.

for example (pseudo code):

array = ["a","foo","bar","foo","blabla","foo"]

string = "foo"

count_appearance(array, string) will return 3 because array has 3 appearances of "foo" string.

Call this method from the main method, and print returned result from the main method.

--------------------------------------------------------------

import java.util.*;

class Main { public static void main(String[] args) { //TODO Complete the code

} public static int count_appearance(String[] arr,String t) { //Write Your Code Here

return -1; } //end count_appearance

}

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!