Given int[] arr = [7, 2, 5, 2]; and int index;, how can I use a for loop to make sure that index is assigned to 1 (the first index at which 2 was observed in arr) and not 3 (the last index at which 2 was observed in arr)?
I'm thinking using a break; statement but I'm not sure how to implement the syntax.