Question
If wordList is a variable of type String[] and word is a variable of type String
int count = countOccurrences(wordList, word);
Test your method using an array of String and an array of Integer (not int, can’t use primitive types with generics).
Solution Preview
This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.
public static void main(String[] args){
String[] test = {"test1", "test2", "test1", "test3", "test4", "test5", "test1"};
int occCount = countOccurrences(test, "test1");
System.out.println("Test 1 occured " + occCount + " times in the array");
Integer[] test2 = {1, 4, 5, 24, 53, 23, 53, 24, 59, 35 ,24, 43, 53, 26, 24};
occCount = countOccurrences(test2, 53);
System.out.println("53 occured " + occCount + " times in the array");
}
}...