Skip to content

Instantly share code, notes, and snippets.

@aniketmlk6
Created July 3, 2021 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aniketmlk6/950903904bfe6484c5ff1a926acdf313 to your computer and use it in GitHub Desktop.
Save aniketmlk6/950903904bfe6484c5ff1a926acdf313 to your computer and use it in GitHub Desktop.
public static void main(String[] args) {
String term = "Java is awesome";
char search_term = 'a';
int counter = 0;
for (int i = 0; i < term.length(); i++) {
if (term.charAt(i) == search_term) {
counter++;
}
}
System.out.println("Character '" + search_term + "' occured " + counter + " times");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment