/// Returns the index of target in items, or -1 if it is absent.
int linearSearch(int[] items, int target) {
    for (int i = 0; i < items.length; i++) {
        if (items[i] == target) {
            return i;
        }
    }
    return -1;
}

void main() {
    int[] numbers = {17, 4, 23, 8, 42, 15, 9};

    IO.println(linearSearch(numbers, 42));
    IO.println(linearSearch(numbers, 99));
}

// From Groundwork, chapter 11 (ch11-searching-and-sorting), box 1.
// This example is from Groundwork, licensed CC BY-NC-SA 4.0.
// Run with: java ch11_01.java
