I have an array that I made that consists of first names. I have a search function that searches through the elements of the array and it works fine. However, for multiple elements of an array, I cannot find out how to print how many results were returned. For example, if "John" in my example is found, which it is, I do not know how to show that there were multiple results found. Someone please help me. I need to get "count" to increase 1 time for each result found. Here is my code: `
import java.util.*;
class Search {
public static void main(String[] args) {
Scanner search = new Scanner(System.in);
String[] firstName = new String[]{"John", "Thomas", "Samuel", "Chris", "Daniel", "Joey", "David", "Joshua", "Michael", "John"};
Arrays.sort(firstName);
System.out.print("Enter a search term: ");
String name = search.next();
int i;
boolean foundIt = false;
search:
for (i = 0; i < firstName.length; i++) {
if (firstName[i] == name) {
foundIt = true;
}
}
if (foundIt = true){
System.out.println("Your search term of " + name + " produced " + count + " search results");
}
else {
System.out.println("Your search term of " + name + " did not return any results");
}
}
}
'