I have an array as:
["Front", "Front", "Back", "Back", "Side", Side]
What I need to do is return the indices for all matching occurrences of a particular string. For example, if inputting: "Front"
it should return [0,1]
, input "Side"
, should return [4,5]
and "Back"
would return [2,3]
How can this be accomplished in Java efficiently?