1String stringName = "Hello";
2String characterToFind = "l";
3//This example will find all the Ls in this string and will print the index of
4//it as soon as it is detected
5
6for(int i = 0; i < stringName.length(); i++){
7 if(stringName.substring(i, i+1).equals(characterToFind)){
8 System.out.println(characterToFind + "found at " + i);
9 }
10
11}
1int index = word.indexOf(guess);
2while (index >= 0) {
3 System.out.println(index);
4 index = word.indexOf(guess, index + 1);
5}
6