int positionOf(String word, char letter) {
    for (int i = 0; i < word.length(); i++) {
        if (word.charAt(i) == letter) {
            return i;
        }
    }
    return -1;
}

void main() {
    IO.println(positionOf("banana", 'n'));
    IO.println(positionOf("banana", 'z'));
}

// From Groundwork, chapter 6 (ch06-methods), box 8.
// This example is from Groundwork, licensed CC BY-NC-SA 4.0.
// Run with: java ch06_08.java
