← Back to Generics
Question 184
Find the Index of a Generic Value
Find the Index of a Generic Value
Complete the generic methodfindIndexthat searches an array for a target value and returns the index of the first match. Return-1if 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 — 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.