How to replicate a functioning indexOf method without using indexOf in Java?
<p>I want to find the index of certain letters in a string without using the indexOf method. I was able to do this, but I also want any letters that are not in the word/string to return a value of -1. I tried an if statement and it returns -1 as well as the index of the letter. I just want one or the other. Is there a way to do this? Thanks!</p>

<pre><code>import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class randomtest {
    public static void main (String args[]) {
            String text = "Cheeki Breeki";
            String letterToFind = "C";
            Pattern word = Pattern.compile(letterToFind);
            Matcher match = word.matcher(text); 
            if (!letterToFind.equals(text)) {
                System.out.println("-1");
            }

            while (match.find()) {
            System.out.println("Found letter at index "+ match.start());
        }

       } 

}
</code></pre>