X1080: countOccurrences

Implement the following method so that it counts the number of times the target character appears in the given string and returns the count.

Examples:

countOccurrences("abbcdd", 'b') -> 2
countOccurrences("XXXXX", 'X') -> 5
countOccurrences("12345", ' ') -> 0

Your Answer:

Reset

Practice a different Java exercise

Feedback

Your feedback will appear here when you check your answer.