Find the Index of a Generic Value
mediumQuestion 184Complete the generic method findIndex that searches an array for a target value and returns the index of the first match. Return -1 if the value is not found.
Use .equals() for comparison.
IMPORTANT: Do NOT write a main method. A hidden test will search for "banana" (index 1) and "grape" (not found) in a String array and print the resulting indexes.
Expected output
1 -1
= newline. The output ends with a newline, so print one after the last line.
Hints3 available
Sign in to use hintsTopics
GenericsMethods
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (sysout, psvm, fori)
Your output
Run your code to see the output here...
Test cases
Run your code to see test case results.