Skip to content

Instantly share code, notes, and snippets.

@aniketmlk6
Created July 1, 2021 15:52
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/325ac570bcd567c16ffe88115f5e74c7 to your computer and use it in GitHub Desktop.
Save aniketmlk6/325ac570bcd567c16ffe88115f5e74c7 to your computer and use it in GitHub Desktop.
public static void main(String[] args) {
String input ="Java is awesome";
int counter=0;
for (int i = 0; i < input.length(); i++) {
// if character is not space, increase the counter
if (input.charAt(i)!=' ')
{
counter++;
}
}
System.out.println("Total characters without spaces : "+counter);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment