So I am writing a program supposed to print out the position in the array and the number at that position (by using linear search). Here is what I've got so far, but the output was not what I expected.

Output:

```
Number 0  Linear Search Index At 0
Number 1  Linear Search Index At 1
Number 2  Linear Search Index At 2
Number 2  Linear Search Index At 2
Number 2  Linear Search Index At 2
Number 3  Linear Search Index At 5

```

My expected Output:

```
Number 0  Linear Search Index At 0
Number 1  Linear Search Index At 1
Number 2  Linear Search Index At 2
Number 2  Linear Search Index At 3
Number 2  Linear Search Index At 4
Number 3  Linear Search Index At 5

```

Code:

```
    public class LinearSearch {
    public int linearSearch(int[] array, int key) {
        int size = array.length;
        for ( int i = 0; i < size; i++ ) {
            if ( array[i] == key ) {
                return i;
            }
        }
        return -1;
    }

    public static void main(String[] arg) {
        int[] array = { 0, 1, 2, 2, 3, 3, 4, 4, 5, 6, 8, 8, 9, 9, 9, 10, 11, 12, 13, 15, 16, 20, 21, 22, 22, 23, 24, 24, 26, 27, 27, 28, 30};

        LinearSearch linSearch = new LinearSearch();
        for (int i = 0; i < array.length; i++) {
            System.out.println("Number " + array[i] + " " + " Linear Search Index " +
                linSearch.linearSearch(array, array[i]));
        }
    }

  }

```

Any helps would be great! Thank you!