1public class Exercise6 {
2 public static int findIndex (int[] my_array, int t) {
3 if (my_array == null) return -1;
4 int len = my_array.length;
5 int i = 0;
6 while (i < len) {
7 if (my_array[i] == t) return i;
8 else i=i+1;
9 }
10 return -1;
11 }
12 public static void main(String[] args) {
13 int[] my_array = {25, 14, 56, 15, 36, 56, 77, 18, 29, 49};
14 System.out.println("Index position of 25 is: " + findIndex(my_array, 25));
15 System.out.println("Index position of 77 is: " + findIndex(my_array, 77));
16 }
17}
18
19