← Unit 2 · all exercises
Saved in this browser only

Count a letter

Count how many times the given letter appears in the word. Capitals count as different letters.

int countLetter(String word, String letter)

Solution.java
Loading editor…
Results

Examples

  • countLetter(banana, a) → 3
  • countLetter(banana, z) → 0

There are also 4 hidden tests you can't see. Solve the problem, not the examples.