Skip to content

Instantly share code, notes, and snippets.

@aniketmlk6
Created July 3, 2021 15:39
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/dcd06d83ecdd78faf777cc0d64e7be75 to your computer and use it in GitHub Desktop.
Save aniketmlk6/dcd06d83ecdd78faf777cc0d64e7be75 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 = term.length() - term.replace(String.valueOf(search_term), "").length();
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