id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

james.shockey@austinisd.org > countChar
prev  |  next  |  chance

LASA_AP_WhileLoop_Set01_Problem02

Problem 3: Count Occurrences of Character
Problem: Given a string and a character ch, return the number of times ch appears in the string.
Solution Approach: Use a while loop to iterate over the string and count occurrences of ch.


countChar("xoxo", "x") → 2
countChar("hello", "l") → 2
countChar("java", "j") → 1

...Save, Compile, Run (ctrl-enter)

public int countChar(String str, char ch) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Copyright Nick Parlante 2017 - privacy