counting algorithms code example
Example: Algorithms - count
public int countLetterB(String s) {
int count = 0;
for (char c: s.toCharArray()) {
if (c == 'b') {
count++;
}
}
return count;
}
public int countLetterB(String s) {
int count = 0;
for (char c: s.toCharArray()) {
if (c == 'b') {
count++;
}
}
return count;
}