Skip to content

Instantly share code, notes, and snippets.

@rnaufal
Created January 17, 2020 21:51
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 rnaufal/69202d997e61dea7fead4d23a1ad299c to your computer and use it in GitHub Desktop.
Save rnaufal/69202d997e61dea7fead4d23a1ad299c to your computer and use it in GitHub Desktop.
var totalDigits = 0;
var totalUppercaseChars = 0;
var totalLowercaseChars = 0;
var totalInvalidChars = 0;
for (final char current : string.toCharArray()) {
if (Character.isDigit(current)) {
totalDigits += 1;
} else if (Character.isUpperCase(current)) {
totalUppercaseChars += 1;
} else if (Character.isLowerCase(current)) {
totalLowercaseChars += 1;
} else {
totalInvalidChars += 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment