id/email
password
forgot password | create account
about | help | prefs
ReadingBatcode reading practice

 

 

Warmup 2LookForIt

prev  |  next  |  chance
public static boolean lookForIt(String str, String letter) {
    int c = 0;

    for (int i = 0; i < str.length(); i++)
        if (str.substring(i, i + 1).equals(letter))
            c++;

    return c >= 2;
}
Function Call  Return Value
lookForIt("aaabbb", "a")
lookForIt("bbba", "b")
lookForIt("aa", "c")
lookForIt("a", "d")
lookForIt("", "e")

Experiment with this code on Gitpod.io

⬅ Back